Skip to content

Instantly share code, notes, and snippets.

@sulmansarwar
Created April 10, 2013 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sulmansarwar/5352275 to your computer and use it in GitHub Desktop.
Save sulmansarwar/5352275 to your computer and use it in GitHub Desktop.
read from inputstream and store in file. Java.
/**
* read from input stream and store in file.
*/
InputStream in = .....
File file = File.createTempFile(filename,".dat");
FileOutputStream fos = new FileOutputStream(file,true);
byte[] b = new byte[4096];
while(in.read(b, 0, 4096) != -1)
{
fos.write(b,0,4096);
}
fos.flush();
fos.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment