テキストをチェックする Java メソッドが必要です
2 に答える
0
Java でこれを行う場合は、commons.io Apache ライブラリを使用できます。メソッドiterateFilesを使用してディレクトリ内のファイルを取得し、メソッドcontentEqualsを使用して 2 つのファイルの内容が同じかどうかを確認します。
輸入品
import org.apache.commons.io.FileUtils;
コード
final String path = "C:/...";
List<File> files = new ArrayList<>();
Iterator iterator = FileUtils.iterateFiles(new File(path), null, false);
while(iterator.hasNext()){
// Compare with the rest of the files in the array
final File file = iterator.next();
for (int i = 0; i < files.size(); i++) {
if (FileUtils.contentEquals(file, files.get(i))) {
// Here you can show the file path name
}
}
// Add the file to the array
files.add(file);
}
于 2016-09-30T12:23:51.353 に答える