TXT文件上传下载
来源:互联网 发布:怎样下载开票软件 编辑:程序博客网 时间:2024/06/03 20:29
生成UUID
UUID uuid=UUID.randomUUID(); System.out.println("uuid======"+uuid);
文件上传下载
package com.imt.sys.util;import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.util.UUID;import org.junit.Test;import org.springframework.test.context.TestExecutionListeners;public class uploadText { private String file = ""; //保存字符串到文件中 public void saveAsFileWriter(String content,UUID uuid) { file="F:/text/"+uuid+".txt"; FileWriter fwriter = null; try { fwriter = new FileWriter(file); fwriter.write(content); } catch (IOException ex) { ex.printStackTrace(); } finally { try { fwriter.flush(); fwriter.close(); } catch (IOException ex) { ex.printStackTrace(); } } } //读取本地文本 public String readFileByLines(UUID uuid) { File file = new File("F:/text/"+uuid+".txt"); BufferedReader reader = null; String content=""; try { System.out.println("以行为单位读取文件内容,一次读一整行:"); reader = new BufferedReader(new FileReader(file)); String tempString = null; int line = 1; // 一次读入一行,直到读入null为文件结束 while ((tempString = reader.readLine()) != null) { //加上p标签 ,前台显示可以换行 tempString="<p>"+tempString+"</p>"; // 显示行号 System.out.println("line?????????????????????????????????? " + line + ": " + tempString); content=tempString; line++; } }catch(IOException e){ } return content; }}
阅读全文
0 0
- TXT文件上传下载
- 文件上传下载
- 文件上传下载
- 上传下载文件
- 文件上传下载
- 文件上传下载
- 文件上传下载
- 文件上传下载
- 文件上传下载
- 文件上传下载
- 上传下载文件
- 文件上传下载
- 文件上传下载
- 文件上传下载
- 上传下载文件 .
- 上传下载文件
- 文件上传下载
- 文件上传下载
- Retrofit 中文乱码问题
- Zookeeper的功能以及工作原理
- CPU-bound(计算密集型) 和I/O bound(I/O密集型)
- PB数据窗口
- Windows Serever 2008安装.NET Framework 3.5解决未能加载文件或程序集“System.Web.Extensions, Version=3.5.0.0, Culture
- TXT文件上传下载
- shell 脚本编写学习
- android-View.post与Handler.post的区别
- 问题:在Ubantu系统下,输入ifconfig只有lo,没有eth0,(已解决)
- 加载读取CSV,txt逗号分格值文件
- AtomicInteger简介
- 【Linux 虚拟机】关于如何设置虚拟机网络问题2
- svn merge和branch
- 语系编码转换