当前位置:网站首页>系统临时文件的写和读: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
边栏推荐
- LeetCode 01: T1. 两数之和 ; T1108. IP 地址无效化 ; T344. 反转字符串
- Vscode removes style / syntax highlighting / code highlighting / black background when copying code
- Synchronous use reference of the new version of data warehouse (for beginners)
- TLC549Proteus仿真&Sallen-Key滤波器&AD736Vrms到DC转换&Proteus查看51寄存器值
- pytorch和tensorflow一样展示summary
- 微博评论爬虫+可视化
- The difference between microcomputer and single chip microcomputer
- JS parasitic combinatorial inheritance
- NewTicker使用
- Difference quotient approximation of wechat quotient
猜你喜欢

Japan Fukushima waste dump safety monitoring agreement will recognize the "safety" of the sea discharge plan

求不同采样周期下的传递函数有限零点

微博评论爬虫+可视化

Shell脚本文本三剑客之awk
![[unity entry program] creator kitfps: first person shooting 3D game](/img/2b/78b535973b2898f53752ceeb25ef01.png)
[unity entry program] creator kitfps: first person shooting 3D game

MySQL数据库主从复制集群原理概念以及搭建流程

SMA TE: Semi-Supervised Spatio-Temporal RepresentationLearning on Multivariate Time Series

Principle of PWM and generation of PWM wave

Could not load dynamic library ‘libcudnn.so.8‘;

基于反馈率的控制系统原理
随机推荐
Beyond compare 3 next difference segment / down search arrow not found
Difference quotient approximation of wechat quotient
Keil MDK编译出现..\USER\stm32f10x.h(428): error: #67: expected a “}“错误的解决办法
origin如何作一张图中多张子图是柱状图(或其他图)
广东财政多举措助力稳住粮食安全“压舱石”
LNMP architecture setup (deploy discuz Forum)
Database cli tool docker image
剑指 Offer 笔记: T45. 把数组排成最小的数
STM32 compilation error: l6235e: more than one section matches selector - cannot all be first/l
SMA TE: Semi-Supervised Spatio-Temporal RepresentationLearning on Multivariate Time Series
剑指 Offer 笔记: T58 - II. 左旋转字符串
USB network card drive data stream
Firewalld防火墙
数据库 cli 工具 docker 镜像
Matlab S-function详解
omitempty在go中的使用
Principle of PWM and generation of PWM wave
解决方案:Can not issue executeUpdate() or executeLargeUpdate() for SELECTs
How to make a graph? Multiple subgraphs in a graph are histogram (or other graphs)
LAN SDN hard core technology insider 23 looking forward to the future - RDMA (Part 1)