Here you can find the source of saveInputStream(InputStream is, String filePath)
public static void saveInputStream(InputStream is, String filePath)
//package com.java2s; //License from project: Apache License import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static void saveInputStream(InputStream is, String filePath) { FileOutputStream fos = null; try {/* w w w. j a va 2 s .c om*/ fos = new FileOutputStream(filePath); byte[] buf = new byte[1024]; int len; while ((len = is.read(buf)) != -1) { fos.write(buf, 0, len); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (is != null) { try { is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (fos != null) { try { fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }