默认已经知道: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方法相关推荐

  1. MultipartFile的transferTo方法注意事项

    前言 最近用SpringBoot写文件上传功能,使用参数绑定之后确实是非常的方便了.但是,项目部署就出现了问题,搞得我一脸懵逼.后来,才发现是因为我使用了相对路径导致的,这个绝对是一个坑人的地方,不过 ...

  2. MultipartFile的transferTo方法的坑

    前言 最近用SpringBoot写文件上传功能,使用参数绑定之后确实是非常的方便了.但是,项目部署就出现了问题,搞得我一脸懵逼.后来,才发现是因为我使用了相对路径导致的,这个绝对是一个坑人的地方,不过 ...

  3. 【SpringBoot】MultipartFile的transferTo()方法详解

    目录 背景 问题 源码分析 后记 背景 我们在编写Spring Boot应用中,常会遇到文件上传问题,Spring Boot Web提供了MutipartFile的文件支持,具体和File的区别可自行 ...

  4. MultipartFile的transferTo方法

    @RequiresPermissions("admin:user:import") @RequiresPermissionsDesc(menu = {"用户管理" ...

  5. transferto方法的应用_Java MultipartFile.transferTo方法代碼示例

    本文整理匯總了Java中org.springframework.web.multipart.MultipartFile.transferTo方法的典型用法代碼示例.如果您正苦於以下問題:Java Mu ...

  6. 学习笔记:MultipartFile中的transferTo方法

    学习笔记:MultipartFile中的transferTo(dest) 在文件上传的时候,MultipartFile中的transferTo(dest)方法只能使用一次; 并且使用transferT ...

  7. transferTo方法

    在文件上传的时候,MultipartFile中的transferTo(dest)方法只能使用一次;并且使用transferTo方法之后不可以在使用getInputStream()方法;否则再使用get ...

  8. MultipartFile中transferto报错

    MultipartFile中transferto报错 java.io.FileNotFoundException: C:\Users\Administrator\AppData\Local\Temp ...

  9. transferto的流这么关闭_Java 9中InputStream的transferTo()方法的重要性?

    在Java 9中,transferTo()方法已添加到InputStream类中.该方法已用于在Java中将数据从输入流复制到输出流.这意味着它将从输入流中读取所有字节,然后按读取顺序将字节写入输出流 ...

最新文章

  1. 进阶必备:素数筛法(欧拉,埃氏筛法)
  2. 4.5 计算机网络之网络层路由选择协议(自治系统AS、RIP、OSPF、BGP)
  3. linux网路编程之多线程并发服务器
  4. 【Python CheckiO 题解】Striped Words
  5. 【机器学习】熵、决策树、随机森林 总结
  6. ElasticSearch 最全详细使用教程
  7. 【数据库系统工程师】数据库系统工程师考情分析
  8. 卢菲菲数字编码表_学技树
  9. 固态硬盘系统经常假死_Win7固态硬盘假死卡顿解决方法
  10. c语言生成正弦波,方波等mif
  11. html下拉框背景怎么设透明度,css怎么设置背景图片半透明 css设置图片作为背景的透明度...
  12. FCN——Semantic Segmentation的开山之作之论文解析
  13. html 6位数支付密码,支付宝支付密码怎么设置长密码 支付宝支付密码取消6位数字密码设置长密码的方法...
  14. Unity 重要概念
  15. 网站403报错问题原因解答
  16. 基于STM32F103系列单片机四路定时器电机编码器模式配置过程附源码
  17. 哪个牌子的充电宝转化率高?转化率高的充电宝推荐
  18. php 节日,PHP节假日
  19. 通达信日线数据转换为csv和excel格式
  20. 抖音上农民伯伯出的题,真的会难倒清华北大的高材生吗?

热门文章

  1. autoconf与automake使用简解
  2. 《JAVA程序性能优化》总结
  3. Excel提取身份证出生日期②
  4. 对持久层、持久性、持久化的讨论
  5. 国产热门操作系统Deepin试用感受
  6. 区块链农场经营游戏NFT游戏开发
  7. Java实现doc转docx
  8. js 百度地图标记定位(一)
  9. C# 网络编程之获取本机名、ip地址、域名、物理位置
  10. sql UPDATE的时候可以使用join吗