Skip to content

Instantly share code, notes, and snippets.

@agiertli
Created April 8, 2016 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agiertli/646ce83fae9bbcbec9dc1e0335ff5809 to your computer and use it in GitHub Desktop.
Save agiertli/646ce83fae9bbcbec9dc1e0335ff5809 to your computer and use it in GitHub Desktop.
public String convertStreamToString(BufferedInputStream in) throws IOException {
int last = 0;
int current;
StringBuilder sb = new StringBuilder();
while ((current = in.read()) != -1) {
// Read the input
// Escape sequence met
if (last == '\r' && current == '\n') {
break;
}
last = current;
sb.append((char) current);
}
return sb.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment