public static void readAsFile(InputStream inStream, File file)
throws Exception
{//读取网络InputStream
FileOutputStream
outStream = new
FileOutputStream(file); //自定义FileOutputStream对象
byte[] buffer =
new byte[1024]; //自定义byte[]缓冲
int len =
-1; //用于记录InputStream流的读入字节长度
while( (len =
inStream.read(buffer)) != -1 )
{
outStream.write(buffer, 0,
len); //写入文件
}
outStream.close(); //关闭FileOutputStream流
inStream.close(); //关闭InputStream流
}
原文地址:http://www.cnblogs.com/wdc224/p/3704404.html