标签:ringbuf path end pst code adl put 字符 输入流
解析TXT文件步骤:
1、File file = new file(‘D:\a.txt‘);// 创建文件对象
2、String code = ReadFile.codeString(file.getAbsolutePath());//获得文件编码
3、InputStreamReader read = new InputStreamReader(new FileInputStream(file),code);//使用InputStreamReader读取文件流
4、BufferedReader bufferedReader = new BufferedReader(read); //从字符输入流中读取文本,缓存到内存中
5、String lineTxt_cr = null;//行读字符串
StringBuffer xpStr = new StringBuffer();//文件文本字符串
while((lineTxt_cr = bufferedReader.readLine()) != null){
//处理字符串lineTxt_cr
xpStr.append(lineTxt_cr);
}
标签:ringbuf path end pst code adl put 字符 输入流
原文地址:http://www.cnblogs.com/chai-blogs/p/6527063.html