Skip to content

Instantly share code, notes, and snippets.

@tachesimazzoca
Created January 27, 2019 14:37
Show Gist options
  • Save tachesimazzoca/482491b4015890a366f1e77cef088a60 to your computer and use it in GitHub Desktop.
Save tachesimazzoca/482491b4015890a366f1e77cef088a60 to your computer and use it in GitHub Desktop.
public class IOUtils {
public static String toString(InputStream input, String charset) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int n = 0;
while ((n = input.read(buffer)) != -1) {
output.write(buffer, 0, n);
}
return output.toString(charset);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment