From 44c94bb589aa56b45eda4bda7583c90aa7dbc2e4 Mon Sep 17 00:00:00 2001 From: FormatFa <1758759399@qq.com> Date: 2023年10月14日 10:35:22 +0800 Subject: [PATCH] Create dump.java --- dump.java | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 dump.java diff --git a/dump.java b/dump.java new file mode 100644 index 0000000..44b6601 --- /dev/null +++ b/dump.java @@ -0,0 +1,70 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package readtest; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.apache.commons.io.FileUtils; + +/** + * + * @author root + */ +public class Readtest { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) throws IOException { + // TODO code application logic here + List result = new ArrayList(); + System.out.println("fl="+new File("C:\\Users\\root\\Downloads\\Java-Interview-main").listFiles().length); + readDir(new File("C:\\Users\\root\\Downloads\\Java-Interview-main"),result); + String resultStr = ""; + for(String item:result) { + resultStr += item; + resultStr += "\n"; + } + FileUtils.writeStringToFile(new File("result.txt"), resultStr, "utf-8"); + } + public static void readDir(File dir,List resultContainer) throws IOException { + File[] files = dir.listFiles(); + for(File file : files) { + + if(file.isDirectory()) { + + readDir(file,resultContainer); + } + else { + + if(!file.getName().endsWith(".md")) { + System.out.println("skip:"+file.getName()); + continue; + } + int readCount = 0; + System.out.println(file.getName()); + String text = FileUtils.readFileToString(file, "utf-8"); + String lines[] = text.split("\n"); + for(String line:lines) { +// System.out.println(line); + line=line.trim(); + if( (line.startsWith("##")||line.startsWith("> "))&&(line.endsWith("?")||line.endsWith("?"))) { + + line= line.replace("#","").replace(">",""); + line = line.replaceAll("\\d+.", "").trim(); + resultContainer.add(line); + readCount+=1; +// System.out.println(line); + + } + } + System.out.println("cou="+readCount); + + } + } + } +}

AltStyle によって変換されたページ (->オリジナル) /