Skip to content

Instantly share code, notes, and snippets.

@dwelch2344
Created September 25, 2013 19:37
Show Gist options
  • Select an option

  • Save dwelch2344/6704913 to your computer and use it in GitHub Desktop.

Select an option

Save dwelch2344/6704913 to your computer and use it in GitHub Desktop.
a standalone class for doing byte copying...
public class IOUtils
public ByteArrayOutputStream readBytes(InputStream is) throws IOException{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[1024 * 16];
while ((nRead = is.read(data, 0, data.length)) != -1) {
baos.write(data, 0, nRead);
}
baos.flush();
return baos;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment