Here you can find the source of saveStream(InputStream is, String savePath)
private static void saveStream(InputStream is, String savePath) throws IOException
//package com.java2s; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { private static int BUFF_SIZE = 1024; private static void saveStream(InputStream is, String savePath) throws IOException { FileOutputStream output = new FileOutputStream(savePath); int readlen; byte[] buf = new byte[BUFF_SIZE]; while ((readlen = is.read(buf)) > 0) output.write(buf, 0, readlen); output.close();/* www .ja v a 2 s. com*/ is.close(); } }