Atitit sumdoc everything index tech and index log
目录
1.1. Atitit 日志记录的三个trace跟踪等级文件夹级别,文件级别,行级 1
2. D:\新建文件夹 (6)\00 sumdoc everything index 2000-20191231 1
2.1. /sumdoclist/src/comattilax/sumdoclist/geneEverythingIndex.java 2
D:\新建文件夹 (6)\00 sumdoc everything index 2000-20191231>dir /b
00sumdoc-2019-everythingIndexOutput t11-t431
00sumdoc-2019-everythingIndexOutput t11-t431.rar
l4 sumdoc s2000-201801 everthing index
l4 sumdoc s2000-201801 everthing index.rar
l4 sumdoc s2018 untils9 everthing index
l4 sumdoc s2018 untils9 everthing index.rar
l4 sumdoc s20180901-1231 everthing index
l4 sumdoc s20180901-1231 everthing index.rar
public class geneEverythingIndex {
static org.apache.log4j.Logger logger = Logger.getLogger(FileTraveList.class);
//static static walkFileTreeLogger
static int listSum;
public static void main(String[] args) throws IOException {
// t1("D:\\l3 sumdoc s2018 torb31 v2 t1_filelist.txt");
trave_dir("C:\\Users\\Administrator\\Documents\\sumdoc 2019 zipver","d:\\00sumdoc-2019-everythingIndexOutput");
// String f = "s9 doc compc v2 s025\\河北英创科技有限公司测评资料\\短信接口安全评测资料补充\\Atitit 项目工作常见问题与 应急预案(1).docx";
// String zipname = getZipName(f);
//
// String filename = getmainFilename(f);
//
// String newFile = zipname + "__" + filename;
// System.out.println(newFile);
System.out.println("--");
}
private static void trave_dir(String dir, String dirout) throws IOException {
// 处理下级多层目录
Files.walkFileTree(Paths.get(dir), new SimpleFileVisitor<Path>() {
@Override // 处理目录
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
System.out.println(dir);
return FileVisitResult.CONTINUE;
}
// 处理文件
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// return super.visitFile(file, attrs);
String fpath = file.toString();
String string = "\t正在访问" + fpath + "文件";
System.out.println(string);
logger.info(string);
String ext=FilenameUtils.getExtension(file.toFile().getAbsolutePath());
//System.out.println(ext);
if(!ext.equals("txt"))
return FileVisitResult.CONTINUE; // 没找到继续找
List<String> lines=FileUtils.readLines(file.toFile(),"gbk");
listSum=listSum+lines.size();
logCurfile(file, lines);
int linenum=0;
for (String line : lines) {
linenum++;
String fileSingle=line.trim();
try {
Map m=Maps.newLinkedHashMap();
m.put("dirlistFilename",file.toFile().getAbsolutePath());
m.put("linenum",linenum);
m.put("linenumSource",line);
String basename=FilenameUtils.getBaseName(fileSingle);
basename=filenameEncode(basename);
String everythingIndexFilename=dirout+"\\"+basename+".plshdr.txt";
logger.info(everythingIndexFilename);
File file2 = new File(everythingIndexFilename);
//should be all json struts..
FileUtils.writeStringToFile(file2, "\r\n"+JSON.toJSONString(m, true), true);
} catch (Exception e) {
logger.error(e);
}
}
return FileVisitResult.CONTINUE; // 没找到继续找
}
});
Map traceM=Maps.newLinkedHashMap();
traceM.put("dir", dir);
traceM.put("listSum", listSum);
logger.info(JSON.toJSONString(traceM));
// 处理目录
}