diff --git a/src/main/java/org/bridj/Platform.java b/src/main/java/org/bridj/Platform.java index 16ad0a6d..651f5e97 100644 --- a/src/main/java/org/bridj/Platform.java +++ b/src/main/java/org/bridj/Platform.java @@ -40,6 +40,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -710,8 +711,8 @@ static File extractEmbeddedLibraryResource(String name) throws IOException { static File createTempDir(String prefix) throws IOException { File dir; for (int i = 0; i < maxTempFileAttempts; i++) { - dir = File.createTempFile(prefix, ""); - if (dir.delete() && dir.mkdirs()) { + dir = Files.createTempDirectory(prefix).toFile(); + if (true) { return dir; } } diff --git a/src/test/java/org/bridj/NativeLibraryTest.java b/src/test/java/org/bridj/NativeLibraryTest.java index 099c142e..494c41c8 100644 --- a/src/test/java/org/bridj/NativeLibraryTest.java +++ b/src/test/java/org/bridj/NativeLibraryTest.java @@ -35,6 +35,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.file.Files; import org.bridj.ann.Library; import org.bridj.ann.Runtime; @@ -46,9 +47,7 @@ public class NativeLibraryTest { static File tempDir() throws IOException { - File f = File.createTempFile("bridj", "natlibtest"); - f.delete(); - f.mkdir(); + File f = Files.createTempDirectory("bridj" + "natlibtest").toFile(); f.deleteOnExit(); return f; }