|
@@ -1,5 +1,5 @@ |
|
|
/* |
|
|
/* |
|
|
* Copyright 2001-2004 The Apache Software Foundation |
|
|
|
|
|
|
|
|
* Copyright 2001-2005 The Apache Software Foundation |
|
|
* |
|
|
* |
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
* you may not use this file except in compliance with the License. |
|
|
* you may not use this file except in compliance with the License. |
|
@@ -58,11 +58,14 @@ import org.apache.tools.ant.launch.Locator; |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
public class FileUtils { |
|
|
public class FileUtils { |
|
|
|
|
|
|
|
|
|
|
|
private static final FileUtils PRIMARY_INSTANCE = new FileUtils(); |
|
|
|
|
|
|
|
|
//get some non-crypto-grade randomness from various places. |
|
|
//get some non-crypto-grade randomness from various places. |
|
|
private static Random rand = new Random(System.currentTimeMillis() |
|
|
private static Random rand = new Random(System.currentTimeMillis() |
|
|
+ Runtime.getRuntime().freeMemory()); |
|
|
+ Runtime.getRuntime().freeMemory()); |
|
|
|
|
|
|
|
|
private boolean onNetWare = Os.isFamily("netware"); |
|
|
|
|
|
|
|
|
private static boolean onNetWare = Os.isFamily("netware"); |
|
|
|
|
|
|
|
|
// for toURI |
|
|
// for toURI |
|
|
private static boolean[] isSpecial = new boolean[256]; |
|
|
private static boolean[] isSpecial = new boolean[256]; |
|
@@ -106,11 +109,21 @@ public class FileUtils { |
|
|
* Factory method. |
|
|
* Factory method. |
|
|
* |
|
|
* |
|
|
* @return a new instance of FileUtils. |
|
|
* @return a new instance of FileUtils. |
|
|
|
|
|
* @deprecated Use getFileUtils instead, FileUtils do not have state. |
|
|
*/ |
|
|
*/ |
|
|
public static FileUtils newFileUtils() { |
|
|
public static FileUtils newFileUtils() { |
|
|
return new FileUtils(); |
|
|
return new FileUtils(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Method to retrieve The FileUtils, which is shared by all users of this |
|
|
|
|
|
* method. |
|
|
|
|
|
* @return an instance of FileUtils. |
|
|
|
|
|
*/ |
|
|
|
|
|
public static FileUtils getFileUtils() { |
|
|
|
|
|
return PRIMARY_INSTANCE; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Empty constructor. |
|
|
* Empty constructor. |
|
|
*/ |
|
|
*/ |
|
@@ -1356,7 +1369,6 @@ public class FileUtils { |
|
|
return isUpToDate(sourceTime, destTime, getFileTimestampGranularity()); |
|
|
return isUpToDate(sourceTime, destTime, getFileTimestampGranularity()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* close a writer without throwing any exception if something went wrong. |
|
|
* close a writer without throwing any exception if something went wrong. |
|
|
* Do not attempt to close it if the file is null |
|
|
* Do not attempt to close it if the file is null |
|
|