src/share/classes/org/openjdk/jigsaw/Files.java

Print this page

        

*** 105,140 **** } } delete(dst); } - private static void copy(File src, OutputStream out) - throws IOException - { - ensureIsFile(src); - byte[] buf = new byte[8192]; - FileInputStream in = new FileInputStream(src); - try { - try { - int n; - while ((n = in.read(buf)) > 0) { - out.write(buf, 0, n); - } - } finally { - out.close(); - } - } finally { - in.close(); - } - } - private static void copy(File src, File dst) throws IOException { if (dst.exists()) ensureIsFile(dst); ! copy(src, new FileOutputStream(dst)); dst.setLastModified(src.lastModified()); if (src.canExecute()) dst.setExecutable(true, false); } --- 105,123 ---- } } delete(dst); } private static void copy(File src, File dst) throws IOException { if (dst.exists()) ensureIsFile(dst); ! ensureIsFile(src); ! try (FileOutputStream fos = new FileOutputStream(dst)) { ! java.nio.file.Files.copy(src.toPath(), fos); ! } dst.setLastModified(src.lastModified()); if (src.canExecute()) dst.setExecutable(true, false); }
*** 187,199 **** continue; String dp = (dstPath == null) ? sls[i] : dstPath + "/" + sls[i]; if (sf.isDirectory()) { storeTree(sf, dst, deflate, filter, dp); } else { ! copy(sf, newOutputStream(dst, deflate, dp)); } } } public static void storeTree(File src, JarOutputStream dst, boolean deflate, Filter<File> filter) throws IOException --- 170,184 ---- continue; String dp = (dstPath == null) ? sls[i] : dstPath + "/" + sls[i]; if (sf.isDirectory()) { storeTree(sf, dst, deflate, filter, dp); } else { ! try (OutputStream out = newOutputStream(dst, deflate, dp)) { ! java.nio.file.Files.copy(src.toPath(), out); } } + } } public static void storeTree(File src, JarOutputStream dst, boolean deflate, Filter<File> filter) throws IOException