Here you can find the source of writeFile(InputStream fileInputStream, OutputStream outputStream)
public static void writeFile(InputStream fileInputStream, OutputStream outputStream) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static void writeFile(InputStream fileInputStream, OutputStream outputStream) throws IOException { try {/*www .j a v a 2s. c o m*/ byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = fileInputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, bytesRead); } fileInputStream.close(); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } finally { outputStream.close(); } } }