在java中,我必须读取多个文件才能搜索某些文本。文件包含大量html数据,因此在下面的代码帮助下很难阅读html文件的内容。 是使用java获取文件内容的直接方法。我使用下面的代码,但它使我的应用缓慢表明我它的最佳替换在一个循环完成后阅读java中的html文件
try{
FileReader fr=new FileReader("path of the html file");
BufferedReader br= new BufferedReader(fr);
String content="";
while((s=br.readLine())!=null)
{
content=content+s;
}
System.out.println("content is"+content);
}
catch(Exception ex)
{
}
可以使用http://htmlparser.sourceforge.net/ – Abubakkar
@adesh请为什么原因是有Swing和AWT标签 – mKorbel