Here you can find the source of saveFile(InputStream is, String destDir, String fileName)
private static void saveFile(InputStream is, String destDir, String fileName) throws FileNotFoundException, IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { private static void saveFile(InputStream is, String destDir, String fileName) throws FileNotFoundException, IOException { BufferedInputStream bis = new BufferedInputStream(is); BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(new File(destDir + fileName))); int len = -1; while ((len = bis.read()) != -1) { bos.write(len);//from w ww. j av a2s .co m bos.flush(); } bos.close(); bis.close(); } }