聊聊MultipartFile的transferTo方法
默认已经知道:MultipartFile 这个类一般是用来接受前台传过来的文件。
那transferTo方法有什么作用呢?
打开源码:
public void transferTo(File dest) throws IOException, IllegalStateException {if (!this.isAvailable()) {throw new IllegalStateException("File has already been moved - cannot be transferred again");} else if (dest.exists() && !dest.delete()) {throw new IOException("Destination file [" + dest.getAbsolutePath() + "] already exists and could not be deleted");} else {try {this.fileItem.write(dest);if (logger.isDebugEnabled()) {String action = "transferred";if (!this.fileItem.isInMemory()) {action = this.isAvailable() ? "copied" : "moved";}logger.debug("Multipart file '" + this.getName() + "' with original filename [" + this.getOriginalFilename() + "], stored " + this.getStorageDescription() + ": " + action + " to [" + dest.getAbsolutePath() + "]");}} catch (FileUploadException var3) {throw new IllegalStateException(var3.getMessage(), var3);} catch (IOException | IllegalStateException var4) {throw var4;} catch (Exception var5) {throw new IOException("File transfer failed", var5);}}}
意思是说:把dest这个文件路径所指向的文件上传到对应的目录下。
聊聊MultipartFile的transferTo方法相关推荐
- MultipartFile的transferTo方法注意事项
前言 最近用SpringBoot写文件上传功能,使用参数绑定之后确实是非常的方便了.但是,项目部署就出现了问题,搞得我一脸懵逼.后来,才发现是因为我使用了相对路径导致的,这个绝对是一个坑人的地方,不过 ...
- MultipartFile的transferTo方法的坑
前言 最近用SpringBoot写文件上传功能,使用参数绑定之后确实是非常的方便了.但是,项目部署就出现了问题,搞得我一脸懵逼.后来,才发现是因为我使用了相对路径导致的,这个绝对是一个坑人的地方,不过 ...
- 【SpringBoot】MultipartFile的transferTo()方法详解
目录 背景 问题 源码分析 后记 背景 我们在编写Spring Boot应用中,常会遇到文件上传问题,Spring Boot Web提供了MutipartFile的文件支持,具体和File的区别可自行 ...
- MultipartFile的transferTo方法
@RequiresPermissions("admin:user:import") @RequiresPermissionsDesc(menu = {"用户管理" ...
- transferto方法的应用_Java MultipartFile.transferTo方法代碼示例
本文整理匯總了Java中org.springframework.web.multipart.MultipartFile.transferTo方法的典型用法代碼示例.如果您正苦於以下問題:Java Mu ...
- 学习笔记:MultipartFile中的transferTo方法
学习笔记:MultipartFile中的transferTo(dest) 在文件上传的时候,MultipartFile中的transferTo(dest)方法只能使用一次; 并且使用transferT ...
- transferTo方法
在文件上传的时候,MultipartFile中的transferTo(dest)方法只能使用一次;并且使用transferTo方法之后不可以在使用getInputStream()方法;否则再使用get ...
- MultipartFile中transferto报错
MultipartFile中transferto报错 java.io.FileNotFoundException: C:\Users\Administrator\AppData\Local\Temp ...
- transferto的流这么关闭_Java 9中InputStream的transferTo()方法的重要性?
在Java 9中,transferTo()方法已添加到InputStream类中.该方法已用于在Java中将数据从输入流复制到输出流.这意味着它将从输入流中读取所有字节,然后按读取顺序将字节写入输出流 ...
最新文章
- 进阶必备:素数筛法(欧拉,埃氏筛法)
- 4.5 计算机网络之网络层路由选择协议(自治系统AS、RIP、OSPF、BGP)
- linux网路编程之多线程并发服务器
- 【Python CheckiO 题解】Striped Words
- 【机器学习】熵、决策树、随机森林 总结
- ElasticSearch 最全详细使用教程
- 【数据库系统工程师】数据库系统工程师考情分析
- 卢菲菲数字编码表_学技树
- 固态硬盘系统经常假死_Win7固态硬盘假死卡顿解决方法
- c语言生成正弦波,方波等mif
- html下拉框背景怎么设透明度,css怎么设置背景图片半透明 css设置图片作为背景的透明度...
- FCN——Semantic Segmentation的开山之作之论文解析
- html 6位数支付密码,支付宝支付密码怎么设置长密码 支付宝支付密码取消6位数字密码设置长密码的方法...
- Unity 重要概念
- 网站403报错问题原因解答
- 基于STM32F103系列单片机四路定时器电机编码器模式配置过程附源码
- 哪个牌子的充电宝转化率高?转化率高的充电宝推荐
- php 节日,PHP节假日
- 通达信日线数据转换为csv和excel格式
- 抖音上农民伯伯出的题,真的会难倒清华北大的高材生吗?