src/jdk.jpackage/share/classes/jdk/jpackage/internal/IOUtils.java
branchJDK-8200758-branch
changeset 57438 4a31db8d42bd
parent 57407 2c14fbeff1dc
child 57446 5a5b85f00a63
equal deleted inserted replaced
57421:0410ee319681 57438:4a31db8d42bd
   117                     Files.copy(file, dest.resolve(src.relativize(file)));
   117                     Files.copy(file, dest.resolve(src.relativize(file)));
   118                 }
   118                 }
   119                 return FileVisitResult.CONTINUE;
   119                 return FileVisitResult.CONTINUE;
   120             }
   120             }
   121         });
   121         });
   122     }
       
   123 
       
   124     public static void copyFromURL(URL location, File file) throws IOException {
       
   125         copyFromURL(location, file, false);
       
   126     }
       
   127 
       
   128     public static void copyFromURL(URL location, File file, boolean append)
       
   129             throws IOException {
       
   130         if (location == null) {
       
   131             throw new IOException("Missing input resource!");
       
   132         }
       
   133         if (file.exists() && !append) {
       
   134            file.delete();
       
   135         }
       
   136         try (InputStream in = location.openStream();
       
   137             FileOutputStream out = new FileOutputStream(file, append)) {
       
   138 
       
   139             byte[] buffer = new byte[1024];
       
   140             int len;
       
   141             while ((len = in.read(buffer)) != -1) {
       
   142                 out.write(buffer, 0, len);
       
   143             }
       
   144         }
       
   145         file.setReadOnly();
       
   146         file.setReadable(true, false);
       
   147     }
   122     }
   148 
   123 
   149     public static void copyFile(File sourceFile, File destFile)
   124     public static void copyFile(File sourceFile, File destFile)
   150             throws IOException {
   125             throws IOException {
   151         destFile.getParentFile().mkdirs();
   126         destFile.getParentFile().mkdirs();