Read input-stream without 3rd library anyway
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
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
Explicitly set the encoding or you WILL run into problems sometimes down the line: new InputStreamReader(is, "UTF-8") e.g.