/**
* 读取数据流保存到指定的路径下
* @param inputStream 输入流
* @param path 路径
* @param fileName 文件名称
*/
public static void saveFile(InputStream inputStream,String path,String fileName) throws IOException {
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(inputStream);
bos = new BufferedOutputStream(new FileOutputStream(new File(path)));
int len = -1;
while((len = bis.read()) != -1){
bos.write(len);
}
bos.flush(); //刷新
} catch (FileNotFoundException e) {
log.error("文件读取异常!,原因:"+ e);
} catch (IOException e) {
log.error("文件读取异常!,原因:"+ e);
}finally{
if(bis!=null)
bis.close();
if(bos!=null)
bos.close();
}
}