Skip to content

Instantly share code, notes, and snippets.

@XinyueZ
Created October 9, 2015 13:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XinyueZ/440e015b3a1afb692812 to your computer and use it in GitHub Desktop.
Save XinyueZ/440e015b3a1afb692812 to your computer and use it in GitHub Desktop.
Read input-stream without 3rd library anyway
public static String readFromInputStream(InputStream is) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder builder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
return builder.toString();
}
@drjasonharrison
Copy link

This drops line endings, so it does not convert the input data without loss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment