Skip to content

Instantly share code, notes, and snippets.

Created July 13, 2012 13:33
Show Gist options
  • Select an option

  • Save anonymous/3104907 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/3104907 to your computer and use it in GitHub Desktop.
Java InputStream Code.
bytesAvailable = fileInputStream.available();
bufferSize = Math.min(bytesAvailable, maxBufferSize);
buffer = new byte[bufferSize];
// read file and write it into form...
bytesRead = fileInputStream.read(buffer, 0, bufferSize);
while (bytesRead > 0) {
dos.write(buffer, 0, bufferSize);
bytesAvailable = fileInputStream.available();
bufferSize = Math.min(bytesAvailable, maxBufferSize);
bytesRead = fileInputStream.read(buffer, 0, bufferSize);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment