java读取文本内容

java读取文本内容

public static String readHtmlContent(String htmlPath) throws IOException {
    String htmlContentStr = "";
    File htmlFile = new File(htmlPath);
    
    FileReader fileReaderObj = new FileReader(htmlFile);
    BufferedReader bufferedReaderObj = new BufferedReader(fileReaderObj);
    
    String lineStr="";
    while((lineStr=bufferedReaderObj.readLine())!=null) {
        
        htmlContentStr = htmlContentStr+lineStr;
    }
    
    
    bufferedReaderObj.close();
    fileReaderObj.close();
    
    return htmlContentStr;
}

 

 

 

####################

posted @ 2022-05-12 00:11  西北逍遥  阅读(306)  评论(0编辑  收藏  举报