private static String readAsString(InputStream stream) throws IOException {
    StringWriter writer = new StringWriter();
    Reader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
    while (true) {
      int c = reader.read();
      if (c < 0) {
        break;
      }
      writer.write(c);
    }
    return writer.toString();
  }
Reads an InputStream and converts it to a String.
samples/comparison/src/main/java/com/facebook/samples/comparison/urlsfetcher/ImageUrlsFetcher.java