diff --git a/src/main/java/doc/UnZip.java b/src/main/java/doc/UnZip.java index d1247d3..6a32912 100644 --- a/src/main/java/doc/UnZip.java +++ b/src/main/java/doc/UnZip.java @@ -8,6 +8,7 @@ import javax.swing.*; import java.io.*; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; @@ -23,17 +24,7 @@ public static File createTempDirectory() throws IOException { final File temp; - temp = File.createTempFile("temp", Long.toString(System.nanoTime())); - - if(!(temp.delete())) - { - throw new IOException("Could not delete temp file: " + temp.getAbsolutePath()); - } - - if(!(temp.mkdir())) - { - throw new IOException("Could not create temp directory: " + temp.getAbsolutePath()); - } + temp = Files.createTempDirectory("temp" + Long.toString(System.nanoTime())).toFile(); return (temp); } diff --git a/src/main/java/doc_gui/NotebookPanel.java b/src/main/java/doc_gui/NotebookPanel.java index fa8aaf2..72ae244 100644 --- a/src/main/java/doc_gui/NotebookPanel.java +++ b/src/main/java/doc_gui/NotebookPanel.java @@ -29,6 +29,7 @@ import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; +import java.nio.file.Files; import java.util.Vector; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -878,17 +879,7 @@ public void save() { public static File createTempDirectory() throws IOException{ final File temp; - temp = File.createTempFile("temp", Long.toString(System.nanoTime())); - - if(!(temp.delete())) - { - throw new IOException("Could not delete temp file: " + temp.getAbsolutePath()); - } - - if(!(temp.mkdir())) - { - throw new IOException("Could not create temp directory: " + temp.getAbsolutePath()); - } + temp = Files.createTempDirectory("temp" + Long.toString(System.nanoTime())).toFile(); return (temp); }