Here you can find the source of writeStreamToFile(InputStream is, String path)
Parameter | Description |
---|---|
is | a parameter |
path | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static File writeStreamToFile(InputStream is, String path) throws IOException
//package com.java2s; //License from project: LGPL import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { /**/*from w w w.j a v a2s .c o m*/ * Reads an input stream and writes its content to a file * * @param is * @param path * @return * @throws IOException */ public static File writeStreamToFile(InputStream is, String path) throws IOException { File file = new File(path); BufferedInputStream bis = new BufferedInputStream(is); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file)); int inByte; while ((inByte = bis.read()) != -1) { bos.write(inByte); } bis.close(); bos.close(); return file; } }