java将文本内容读入到List中
来源:互联网 发布:仿真软件proteus6 编辑:程序博客网 时间:2024/05/16 11:19
package parsing.MFC;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.util.ArrayList;public class UArrayLst extends ArrayList<String> {/** * */private String charset = "UTF-8";private static final long serialVersionUID = -5784078908561138378L;public void readfile(String filename, String charset) throws IOException {FileInputStream fr = new FileInputStream(filename);if (charset.length() > 0) {this.charset = charset;}InputStreamReader isr = new InputStreamReader(fr, this.charset);BufferedReader bfr = new BufferedReader(isr);String subline = bfr.readLine();while (subline != null) {this.add(subline);subline = bfr.readLine();}bfr.close();isr.close();fr.close();}public void writefile(String filename) throws IOException {FileOutputStream fw = new FileOutputStream(filename);OutputStreamWriter osw = null;if (charset.length() > 0) {osw = new OutputStreamWriter(fw, charset);} else {osw = new OutputStreamWriter(fw);}BufferedWriter bfw = new BufferedWriter(osw);for (int ii = 0; ii < this.size(); ii++) {bfw.write((String) this.get(ii) + "\r\n");// bfw.newLine();}bfw.close();osw.close();fw.close();}}
0 0
- java将文本内容读入到List中
- 将一个文本里的信息,读入到 list 中
- Python-将文本中内容按行读入numpy中
- 将文件中内容读入作为java程序的输入
- 将文本中的内容复制到剪贴板中
- 将屏幕上的内容输出到一个文本中
- C++ 读文件 将文件内容读入到字符串string中
- C++ 读文件 将文件内容读入到字符串string中
- 字符串写入文件 C++ 读文件 将文件内容读入到字符串string中
- Java使用JDBC将文本内容插入到数据库(七)
- 将EXCEL2010数据读入到dataviewgrid中
- 导入文本内容到list control
- c++读入文本所有内容
- C++ 将内容输出到文本
- 将文本内容添加到手机剪切板
- Java 通过URL地址下载文本内容到本地文件中
- C# 将List写入到Text文本
- Java 文本读入读出
- 主键的概念作用及特点
- 实验1后篇——引导linux与uboot命令仿真
- 使用Redis SETNX 命令实现分布式锁
- 【SQL】10g字符串处理函数regexp_substr的用法示例2
- 设计模式
- java将文本内容读入到List中
- POJ 1987 Distance Statistics (树的分治)
- [JAVA基础]JAVA中为什么引入范型?
- Unity3D Shaderlab 学习记录
- 更新Xcode7后网络请求数据问题?
- 大二一年的感受小结
- C++动态链接库DLL-非MFC动态库
- java中Collection与Collections
- 推荐的编程网站