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));
}
}