私はjava.nio.*
ファイル操作に使用する1つのプロジェクトに取り組んでいます。基本的に私の製品はサーバー上で動作していますが、Java7を使用してサーバー上にファイルを作成しています。
Files.createFile(path)//For creating file.
でも削除したいときは
Files.delete(path)
それは私にメッセージを与えます
The process cannot access the file because it is being used by another process.**
ファイルコードを削除...。
Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file,
BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException e)
throws IOException {
if (e == null) {
Files.delete(dir);
return FileVisitResult.CONTINUE;
} else {
// directory iteration failed
throw e;
}
}
});