modules/jdk.packager/src/main/java/com/oracle/tools/packager/IOUtils.java

Print this page




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.oracle.tools.packager;
  27 
  28 import com.oracle.tools.packager.Log;
  29 import java.io.*;
  30 import java.net.URL;
  31 import java.nio.channels.FileChannel;
  32 import java.util.Arrays;
  33 




  34 public class IOUtils {
  35 
  36     public static boolean deleteRecursive(File path) throws FileNotFoundException {
  37         boolean ret = true;
  38         if (!path.exists()) { //nothing to do
  39             return true;
  40         }
  41         if (path.isDirectory()) {
  42             File[] children = path.listFiles();
  43             if (children != null) {
  44                 for (File f : children) {
  45                     ret = ret && deleteRecursive(f);
  46                 }
  47             }
  48         }
  49         return ret && path.delete();
  50     }
  51 
  52     public static void copyFromURL(URL location, File file) throws IOException {
  53         copyFromURL(location, file, false);




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.oracle.tools.packager;
  27 
  28 import com.oracle.tools.packager.Log;
  29 import java.io.*;
  30 import java.net.URL;
  31 import java.nio.channels.FileChannel;
  32 import java.util.Arrays;
  33 
  34 /**
  35  * @deprecated use {@link ToolProvider} to locate the {@code "javapackager"} tool instead.
  36  */
  37 @Deprecated(since="10", forRemoval=true)
  38 public class IOUtils {
  39 
  40     public static boolean deleteRecursive(File path) throws FileNotFoundException {
  41         boolean ret = true;
  42         if (!path.exists()) { //nothing to do
  43             return true;
  44         }
  45         if (path.isDirectory()) {
  46             File[] children = path.listFiles();
  47             if (children != null) {
  48                 for (File f : children) {
  49                     ret = ret && deleteRecursive(f);
  50                 }
  51             }
  52         }
  53         return ret && path.delete();
  54     }
  55 
  56     public static void copyFromURL(URL location, File file) throws IOException {
  57         copyFromURL(location, file, false);