Created
April 8, 2016 15:00
-
-
Save agiertli/646ce83fae9bbcbec9dc1e0335ff5809 to your computer and use it in GitHub Desktop.
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 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