0

我有一个目录,我将在其中查找 ZIP 文件,然后我将使用 TrueZIP 7 从这些 ZIP 文件中提取文件。我的问题是,当我运行应用程序时,当应用程序在 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 ???
4

1 回答 1

1

我忘了打电话unmount

TVFS.umount();

现在我可以删除/编辑文件了。

于 2013-09-22T12:00:14.410 回答