ZIP ファイルを検索するディレクトリがあり、それらの ZIP ファイルから TrueZIP 7 を使用してファイルを抽出します。私の問題は、アプリケーションを実行しているときに、アプリケーションが Windows で実行されている間はファイルを削除/編集できないことです。Windowsでファイルにアクセスしているときに、アプリケーションがファイルに対して何もしていないため、なぜこれらのファイルがJavaアプリにロックされているのかわかりません。
私は次のコードを持っています:
Path dir = FileSystems.getDefault().getPath(directory);
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
for (Path file : stream) {
// do something with file
}
} catch (IOException | DirectoryIteratorException x) {
System.err.println(x);
}
// Why those files are still locked to my app even when execution is here ???