Here you can find the source of SaveFileFromInputStream(InputStream stream, String path, String filename)
public static void SaveFileFromInputStream(InputStream stream, String path, String filename) throws IOException
//package com.java2s; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static void SaveFileFromInputStream(InputStream stream, String path, String filename) throws IOException { FileOutputStream fs = new FileOutputStream(path + "/" + filename); byte[] buffer = new byte[1024 * 1024]; int byteread = 0; while ((byteread = stream.read(buffer)) != -1) { fs.write(buffer, 0, byteread); fs.flush();//w ww . j av a 2 s . c o m } fs.close(); stream.close(); } }