zoukankan      html  css  js  c++  java
  • 怎样快速读完一本网络小说

    首先,这是一遍技术文。

    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");
            //dd[:]dd[:]dd[,]ddd
            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 + "
    ";
                            }
                        }
                        reader.close();
                        read.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
    
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            }
            return fileContent;
        }
    }

     然后,没有然后了。

  • 相关阅读:
    nodejs
    httpClient closeableHttpClient
    re(正则表达式)模块
    ConfigParser模块
    random和string模块
    常用文件操作模块json,pickle、shelve和XML
    time和datetime模块
    os、sys和shutil模块
    内建函数
    生成器、迭代器、装饰器
  • 原文地址:https://www.cnblogs.com/mignet/p/how_to_read_a_network_novel_quickly.html
Copyright © 2011-2022 走看看