FileOutputStream与FileInputStream互相转换
转换 互相
2023-09-11 14:19:52 时间
List<InstorageNoticeDto> noticeList = null; FileOutputStream fos = null; FileInputStream is = null; File file = new File(myfile.getOriginalFilename()); int ch = 0; try { is = (FileInputStream) myfile.getInputStream(); fos = new FileOutputStream(file); while ((ch = is.read()) != -1) { fos.write(ch); } } catch (IOException e1) { throw new Exception("文件导入失败,失败原因:" + e1.getMessage()); } finally { try { fos.flush(); fos.close(); } catch (IOException e) { throw new Exception("文件导入失败,失败原因:" + e.getMessage()); } }
这样通过int值把InputStream流改成OutputStream流完成,不必考虑通过字节数组的长度问题
相关文章
- php 版本号 整数化 mysql存储入库 比较大小【版本处理类,提供版本与数字互相转换】
- xml 与 DataSet 互相转换
- js-时间相关的转换
- lua 时间戳和时间互相转换
- nodejs XML和json互相转换
- Python技巧—list与字符串互相转换
- 日历工具类(一)——公历农历互相转换
- Python技巧—list与字符串互相转换
- 【基础入门题068】数制转换(八)
- Qt编写地图综合应用47-经纬度地址互相转换
- C# 根据KeyEventArgs与组合键字符串相互转换
- DateEdit控件时间格式转换
- C# Enum,Int,String的互相转换 枚举转换
- atitit.XML类库选型及object 对象bean 跟json转换方案
- atitit.标准时间格式 互相转换 秒数 最佳实践
- paip.c++ bcb string 转换操作大总结.
- flutter Uint8List格式的图片和File格式图片的互相转换
- Python之pandas:对dataframe数据的时间日期格式类型字段进行标准化变换(比如将日期类型字段格式2014/1/1转换为2014-1-1)之详细攻略
- 解决Linux下使用ffmpeg转换yuv格式出现的视频图像异常问题
- Java double转decimal_Java中Double与BigDecimal的相互转换
- 练习2-10 重新编写将大写字母转换为小写字母的函数lower,并用条件表达式替代其中的if-else结构。
- Java:String和List互相转换
- iOS十进制切割格式转换
- python利用thriftpy2将json、struct、obj互相转换
- js-jquery-对象与JSON字符串互相转换
- 包含转换重载的程序
- Golang gRPC实践 连载七 HTTP协议转换
- (18)目标检测算法之数据集标签格式转换:json2txt、xml2txt