码迷,mamicode.com
首页 > 其他好文 > 详细

怎样快速读完一本网络小说

时间:2015-08-03 18:22:09      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

首先,这是一遍技术文。

public class NovelReader {
    private static Logger log = LoggerFactory.getLogger(NovelReader.class); 
    public static void main(String[] args) {
        String content = readFile("C:\\Users\\Mignet\\Documents\\雪中悍刀行.txt");
        //\d\d[:]\d\d[:]\d\d[,]\d\d\d
        try {
            FileWriter fw = new FileWriter("C:\\Users\\Mignet\\Documents\\雪中悍刀行_mini.txt");
            fw.write(content);
            fw.flush();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
//        System.out.println(content);
    }
    
    public static String readFile(String filePath) {
        String fileContent = "";
        File file = new File(filePath);
        if (file.isFile() && file.exists()) {
            try {
                InputStreamReader read = new InputStreamReader(
                        new FileInputStream(file), "GBK");
                BufferedReader reader = new BufferedReader(read);
                String line;
                try {
                    while ((line = reader.readLine()) != null) {
                        if((line.contains("第")&&line.contains("章"))||(line.contains("“")||line.contains("”"))){
                            log.info(line);
                            fileContent += line + "\r\n";
                        }
                    }
                    reader.close();
                    read.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
        return fileContent;
    }
}

 然后,没有然后了。

怎样快速读完一本网络小说

标签:

原文地址:http://www.cnblogs.com/mignet/p/how_to_read_a_network_novel_quickly.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!