Here you can find the source of inputstreamtofile(InputStream ins, File file)
public static void inputstreamtofile(InputStream ins, File file)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static void inputstreamtofile(InputStream ins, File file) { OutputStream os = null;/*from w w w.jav a 2 s. c o m*/ try { os = new FileOutputStream(file); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } int bytesRead = 0; byte[] buffer = new byte[8192]; try { while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { os.write(buffer, 0, bytesRead); } os.close(); ins.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }