利用Java下的IO读取或写入xml及word,txt文件,且能有效去除乱码(很适用,且和POI组建比,少占了很多内存),这是我根据网上很多不同的版本,整合而出的一种最易最好的IO读写文件代码;
2010年5月21日 15:58:35
作者:梁玉龙
QQ:295047822 有问题,请大家QQ指教
=======================
---读取---
=======================
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
public static void main(String[] args)
{
String s = new String();
String s1 = new String();;
BufferedReader in=null;
try {
in = new BufferedReader(new InputStreamReader(new FileInputStream(new File("c:\\b.xml")), "UTF-8"));
} catch (FileNotFoundException e1) {
// TODO 自动生成 catch 块
e1.printStackTrace();
}
try {
while((s = in.readLine())!= null)
s1 += s + "\n";
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载
- 1
- 2
- 3
- 4
- 5
- 6
前往页