Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
package org.apache.bookkeeper.util;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.WritableByteChannel;
Expand Down Expand Up @@ -146,14 +148,12 @@ public static File createTempDir(String prefix, String suffix)
*/
public static File createTempDir(String prefix, String suffix, File dir)
throws IOException {
File tmpDir = File.createTempFile(prefix, suffix, dir);
if (!tmpDir.delete()) {
throw new IOException("Couldn't delete directory " + tmpDir);
}
if (!tmpDir.mkdir()) {
throw new IOException("Couldn't create directory " + tmpDir);
}
return tmpDir;
try {
final File tmpDir = Files.createTempDirectory(prefix + suffix).toFile();
return tmpDir;
} catch (IOException e) {
throw new IOException("Could not create temp directory: " + prefix + suffix, e);
}
}

/**
Expand Down