txt报表IO流
来源:互联网 发布:python idle教程 编辑:程序博客网 时间:2024/06/07 16:11
public class CreateFiles {
public void initData(String text) {
String filePath = "/sdcard/选课系统/";
String fileName = "选课系统.txt";
/**
* text:文本内容 filePath:文件路径 fileName:文件名
*/
writeTxtToFile(text, filePath, fileName);
}
// 将字符串写入到文本文件中
public void writeTxtToFile(String strcontent, String filePath,
String fileName) {
// 生成文件夹之后,再生成文件,不然会出错
makeFilePath(filePath, fileName);
String strFilePath = filePath + fileName;
// 每次写入时,都换行写
String strContent = strcontent + "\r\n";
try {
File file = new File(strFilePath);
if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
}
RandomAccessFile raf = new RandomAccessFile(file, "rwd");
raf.seek(file.length());
raf.write(strContent.getBytes());
raf.close();
} catch (Exception e) {
}
}
// 生成文件
public File makeFilePath(String filePath, String fileName) {
File file = null;
makeRootDirectory(filePath);
try {
file = new File(filePath + fileName);
if (!file.exists()) {
file.createNewFile();
}
} catch (Exception e) {
e.printStackTrace();
}
return file;
}
// 生成文件夹
public static void makeRootDirectory(String filePath) {
File file = null;
try {
file = new File(filePath);
if (!file.exists()) {
file.mkdir();
}
} catch (Exception e) {
}
}
0 0
- txt报表IO流
- IO/报表
- java利用io流读取txt文件
- IO流,读取本地txt文件
- IO读写修改txt
- Documentation/io-mapping.txt
- JAVA中IO流读写txt文本代码
- java控制台中电话本 io流写入本地txt中
- io流将txt文件转成map集合的形式
- java IO流(1)处理txt、rtf、doc、docx
- Linux/Documentation/io-mapping.txt
- 报表导出txt自定义换行符
- 润乾报表导出txt文件
- fstream IO流类的使用:C++读取文件txt,循环逐行输出(转)
- 黑马程序员__复制txt mp3 图片〉〉〉〉〉〉IO流技术
- IO流 文件读取, 写入,和复制txt文件代码演示
- 【scala io】scala io操作 txt文件读取和写入
- 润乾报表v4 - 导出txt内容对齐
- UVA 12295 Optimal Symmetric Paths 最短路求方案数
- web.xml、JSP原理、指令
- MediaPlayer(音乐播放器)
- yii 框架的文件上传 (简单实现)
- error while loading shared libraries: xxx.so.x" 错误的原因和解决办法
- txt报表IO流
- Java Enum类的笔记
- 144. Binary Tree Preorder Traversal
- 发送验证码倒计时、图片验证码
- 欢迎使用CSDN-markdown编辑器
- android 全局变量Application类使用
- 创建yum仓库
- XMind错误
- 直角三角形 纪中 1385 数学_斜率