当前位置:网站首页>将文件流(InputStream)写入文件 将上传文件MultipartFile写到文件
将文件流(InputStream)写入文件 将上传文件MultipartFile写到文件
2022-06-09 09:00:00 【tanzongbiao】
将文件流(InputStream)写入文件
方式一:不包裹Buffered(不使用缓冲)
//将文件流(InputStream)写入文件
long size = 0;
FileOutputStream out = new FileOutputStream(strFileFullPath);
int len = -1;
byte[] b = new byte[1024];
while ((len = is.read(b)) != -1) {
out.write(b, 0, len);
size += len;
}
is.close();
out.close();
System.out.println("文件下载 size:" + size);方式二:包裹Buffered(使用缓冲)
//将文件流(InputStream)写入文件
long size = 0;
BufferedInputStream in = new BufferedInputStream(is);
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(strFileFullPath));
int len = -1;
byte[] b = new byte[1024];
while((len = in.read(b)) != -1){
out.write(b, 0, len);
size += len;
}
in.close();
out.close();
System.out.println("文件下载 size:" + size);将上传文件MultipartFile写到文件
//将上传文件MultipartFile写到文件
File dest = new File(strFileFullPath);
file.transferTo(dest);参考:
将一个输入流(InputStream)写入到一个文件中_y_bccl27的博客-CSDN博客_inputstream写入文件
边栏推荐
- 3D編程模式:依賴隔離模式
- MySQL基础 数据库创建基础
- 远程预付费管理系统帮助物业解决收费难统计难问题
- RMAN backup concept_ About image copy
- 微信小程序开发之菜单的创建
- Configuring the environment for RMAN backups_ Configure backup optimization
- Remote prepayment management system helps property management solve the problem of difficult charging and statistics
- How to use alicloud CDN to cache static websites deployed on function computing
- 防火门监控系统对防火门状态进行24小时实时自动巡检
- [texstudio] [3] relatively complete paper typesetting template and bib file reference method
猜你喜欢

环境变量Path误删除

Can I LINQ a JSON- Can I LINQ a JSON?

了解图数据库neo4j(三)

MySQL基础 DML与DDL学习

MySQL基础 查询语句

面向高校 | “云原生技术应用与实践”示范课程项目开放申报

Hvv蓝队指北
![[matlab] [digital simulation] [1] linprog solving linear programming, standard type](/img/e2/584ff7809bcad613b157a6a17d53db.png)
[matlab] [digital simulation] [1] linprog solving linear programming, standard type

安科瑞Acrel-BUS智能照明控制系统在医院的应用

Residual current relay uses residual current transformer to detect residual current and prevent electrical fire
随机推荐
微信小程序开发之菜单的创建
安科瑞配电室综合监控系统实现配电室内环境的在线监测,保障配电室设备的安全运行
JS window object
Mock interview plan; Campus simulated interview plan; Job search simulation interview contest plan; Planning book of simulated job hunting competition of School of economics and management; College st
ESP32学习笔记【WiFi网络篇】-01AP&STA
The energy efficiency management platform of the microgrid of the company promotes the upgrading of the power grid to the energy Internet
[antenna] [2] explanation of some nouns and simple concepts, still
2022-2028 global leisure special sand industry research and trend analysis report
C语言指针
NetCore框架WTM的分表分库实现
MySQL基础 基础认知
Annexe 17 interprétation du programme réseau
Will testing not be replaced by development?
Document sorting (expansion)
JS realizes three-level linkage
English grammar_ adverb of manner
MySQL basic knowledge
2022-2028 global linear LED lighting industry research and trend analysis report
Esp32 learning notes [WiFi network] - 01ap & sta
微信小程序之获取用户基本信息