Here you can find the source of fileWriteOut(InputStream in, String outPath)
public static long fileWriteOut(InputStream in, String outPath) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static long fileWriteOut(InputStream in, String outPath) throws IOException { byte[] buf = new byte[1024]; int length = 0; long fileSize = 0; OutputStream out = null;//from w w w . ja v a 2 s. c o m try { out = new BufferedOutputStream(new FileOutputStream(outPath)); while ((length = in.read(buf)) > 0) { fileSize += length; out.write(buf, 0, length); } } catch (IOException e) { e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); } finally { in.close(); out.close(); in = null; out = null; } return fileSize; } }