Here you can find the source of dumpStream(InputStream in, String file)
public static void dumpStream(InputStream in, String file)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { /** Dump stream to file */ public static void dumpStream(InputStream in, String file) { try {/*from w w w . j a v a 2s .co m*/ File f = new File(file); OutputStream os = new FileOutputStream(f); int ch; while ((ch = in.read()) >= 0) os.write(ch); os.flush(); os.close(); } catch (IOException ex) { throw new RuntimeException(ex); } } }