当前位置:网站首页>系统临时文件的写和读:createTempFile和tempFileContent[通俗易懂]
系统临时文件的写和读:createTempFile和tempFileContent[通俗易懂]
2022-07-27 11:36:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
写java的时候,有时候查到的数据暂时用不到,我们可以把它写到一个临时文件中。
今天写项目的时候发现了这个好方法。
将context的内容写到临时文件
@PostMapping("/temp")
@ResponseBody
String temp(@RequestParam String content) throws IOException {
File tempFile = Files.createTempFile(null, null).toFile();
FileCopyUtils.copy(content.getBytes(StandardCharsets.UTF_8), tempFile);
return tempFile.getName();
}文件被存在这个路径下:C:\Users\my\AppData\Local\Temp
要用的时候再去取出来
json = Utils.tempFileContent(fileName);
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/128213.html原文链接:https://javaforall.cn
边栏推荐
- MATLAB画带延时系统的伯德图
- 剑指 Offer 笔记: T58 - II. 左旋转字符串
- Temporary use of solo, difficult choice of Blog
- 【产品】关于微信产品分析
- 暂用 Solo,博客选择困难
- torch‘ has no attribute ‘inference_ mode‘
- Analysis of the use of JUC framework from runnable to callable to futuretask
- 微机和单片机的区别
- [machine learning whiteboard derivation series] learning notes - support vector machine and principal component analysis
- Database cli tool docker image
猜你喜欢

JS parasitic combinatorial inheritance
![[machine learning whiteboard derivation series] learning notes - support vector machine and principal component analysis](/img/54/dc232f737da99c7097c395a326e74f.png)
[machine learning whiteboard derivation series] learning notes - support vector machine and principal component analysis
![[unity entry program] creator kitfps: first person shooting 3D game](/img/2b/78b535973b2898f53752ceeb25ef01.png)
[unity entry program] creator kitfps: first person shooting 3D game

TapNet: Multivariate Time Series Classification with Attentional Prototypical Network

Principle, concept and construction process of MySQL database master-slave replication cluster

Shell script text three swordsmen sed

Analysis of the use of JUC framework from runnable to callable to futuretask

基于反馈率的控制系统原理

Shell编程之正则表达式(Shell脚本文本三剑客之grep)

JUC框架 从Runnable到Callable到FutureTask 使用浅析
随机推荐
Leetcode 03: t58. Length of the last word (simple); Sword finger offer 05. replace spaces (simple); Sword finger offer 58 - ii Rotate string left (simple)
1. Introduction and basic use of flume
求不同采样周期下的传递函数有限零点
LeetCode 04: T26. 删除排序数组中的重复项(简单); 剑指 Offer 67. 把字符串转换成整数(中等); 面试题 01.08. 零矩阵 (简单)
Keil MDK compilation appears..\user\stm32f10x H (428): error: # 67: expected a "}" wrong solution
Sword finger offer notes: T53 - ii Missing numbers from 0 to n-1
go语言之sync.Map
Vscode removes style / syntax highlighting / code highlighting / black background when copying code
JS string method summary
Database cli tool docker image
LAN SDN hard core technology insider 24 outlook for the future - RDMA (middle)
torch‘ has no attribute ‘inference_ mode‘
V-show失效问题
Sword finger offer note: T39. Numbers that appear more than half of the time in the array
LAN SDN hard core technology insider 25 looking forward to the future - RDMA (Part 2)
torch‘ has no attribute ‘inference_mode‘
Regular expression of shell programming (grep of shell script text three swordsmen)
omitempty在go中的使用
Source code compilation and installation lamp
图像分割 vs Adobephotoshop(PS)