Here you can find the source of SaveFileFromInputStream(InputStream in, String fileName, String path)
public static void SaveFileFromInputStream(InputStream in, String fileName, String path)
//package com.java2s; //License from project: Apache License import java.io.FileOutputStream; import java.io.InputStream; public class Main { public static void SaveFileFromInputStream(InputStream in, String fileName, String path) { try {/* w w w . jav a 2 s . c o m*/ FileOutputStream fs = new FileOutputStream(path + fileName); byte[] buffer = new byte[1024 * 1024]; int bytesum = 0; int byteread = 0; while ((byteread = in.read(buffer)) != -1) { bytesum += byteread; fs.write(buffer, 0, byteread); fs.flush(); } fs.close(); in.close(); } catch (Exception e) { e.printStackTrace(); } } }