Skip to content

Instantly share code, notes, and snippets.

@maoo
Created December 23, 2012 14:10
Show Gist options
  • Save maoo/4363591 to your computer and use it in GitHub Desktop.
Save maoo/4363591 to your computer and use it in GitHub Desktop.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int red = 0;
boolean finished = false;
byte[] tempdata = new byte[1024];
while (!finished) {
red = instr.read(tempdata);
if (red > 0) {
baos.write(tempdata, 0, red);
} else {
finished = true;
}
}
baos.flush();
byte[] data = baos.toByteArray();
baos.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment