悠然哈哈哈

导航

java 解析txt/html文件

package util.read;

import java.io.BufferedReader;
import java.io.FileReader;

public class ReadFromFile {

private static String readHTMLFile(String fileName){
String sHtml="";
try {
BufferedReader brd = new BufferedReader(new FileReader(fileName));
char[] str = new char[50000];
brd.read(str);
sHtml = new String(str);
} catch (Exception e) {
e.printStackTrace();
}
return sHtml;
}

public static void main(String[] args) {
String fileName = "C:/Users/Administrator/Desktop/aa.txt";

System.out.println(ReadFromFile.readHTMLFile(fileName));

String filepath= "C:/Users/Administrator/Desktop/jqueryeasyui/Untitled-1.html";

System.out.println(ReadFromFile.readHTMLFile(filepath));
}
}

posted on 2015-03-16 10:13  悠然886  阅读(480)  评论(0编辑  收藏  举报