Skip to content

Instantly share code, notes, and snippets.

@ananthakumaran
Created April 14, 2010 04:12
Show Gist options
  • Save ananthakumaran/365440 to your computer and use it in GitHub Desktop.
Save ananthakumaran/365440 to your computer and use it in GitHub Desktop.
public static byte[] readFully(InputStream input) throws IOException {
byte[] buffer = new byte[8192];
int bytesRead;
ByteArrayOutputStream output = new ByteArrayOutputStream();
while ((bytesRead = input.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
}
return output.toByteArray();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment