我的目的是使用存储在列表中的关键字索引包含pdf文件(以及其他文件类型)的任意目录.我有一个传统的解决方案,我听说使用例如SimpleGraph的基于图形的解决方案可以更优雅/高效并且独立于目录结构.
基于图形的解决方案(例如SimpleGraph)会是什么样的?
传统解决方案
// https://stackoverflow.com/a/14051951/1497139
List<File> pdfFiles = this.explorePath(TestPDFFiles.RFC_DIRECTORY, "pdf");
List<PDFFile> pdfs = this.getPdfsFromFileList(pdfFiles);
…
for (PDFFile pdf:pdfs) {
// https://stackoverflow.com/a/9560307/1497139
if (org.apache.commons.lang3.StringUtils.containsIgnoreCase(pdf.getText(), keyWord)) {
foundList.add(pdf.file.getName()); // here we access by structure (early binding)
// - in the graph solution by name (late binding)
}
}
Run Code Online (Sandbox Code Playgroud)