Class FileUtil
- java.lang.Object
-
- org.apache.derby.iapi.services.io.FileUtil
-
public abstract class FileUtil extends java.lang.ObjectA set of public static methods for dealing with File objects.
-
-
Constructor Summary
Constructors Constructor and Description FileUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static booleancopyDirectory(StorageFactory storageFactory, StorageFile from, java.io.File to, byte[] buffer, java.lang.String[] filter, boolean copySubDirs)static booleancopyDirectory(WritableStorageFactory storageFactory, java.io.File from, StorageFile to)static booleancopyDirectory(WritableStorageFactory storageFactory, java.io.File from, StorageFile to, byte[] buffer, java.lang.String[] filter)static booleancopyFile(java.io.File from, java.io.File to, byte[] buf)static booleancopyFile(StorageFactory storageFactory, StorageFile from, java.io.File to)static booleancopyFile(StorageFactory storageFactory, StorageFile from, java.io.File to, byte[] buf)static booleancopyFile(WritableStorageFactory storageFactory, java.io.File from, StorageFile to)static booleancopyFile(WritableStorageFactory storageFactory, java.io.File from, StorageFile to, byte[] buf)static booleancopyFile(WritableStorageFactory storageFactory, StorageFile from, StorageFile to)static voidlimitAccessToOwner(java.io.File file)Use when creating new files.static booleanremoveDirectory(java.io.File directory)Remove a directory and all of its contents.static java.lang.StringstripProtocolFromFileName(java.lang.String originalName)Remove the leading 'file://' protocol from a filename which has been expressed as an URL.
-
-
-
Method Detail
-
removeDirectory
public static boolean removeDirectory(java.io.File directory)
Remove a directory and all of its contents. The results of executing File.delete() on a File object that represents a directory seems to be platform dependent. This method removes the directory and all of its contents.- Returns:
- true if the complete directory was removed, false if it could not be. If false is returned then some of the files in the directory may have been removed.
-
copyFile
public static boolean copyFile(java.io.File from, java.io.File to, byte[] buf)
-
copyDirectory
public static boolean copyDirectory(StorageFactory storageFactory, StorageFile from, java.io.File to, byte[] buffer, java.lang.String[] filter, boolean copySubDirs)
-
copyFile
public static boolean copyFile(StorageFactory storageFactory, StorageFile from, java.io.File to)
-
copyFile
public static boolean copyFile(StorageFactory storageFactory, StorageFile from, java.io.File to, byte[] buf)
-
copyDirectory
public static boolean copyDirectory(WritableStorageFactory storageFactory, java.io.File from, StorageFile to)
-
copyDirectory
public static boolean copyDirectory(WritableStorageFactory storageFactory, java.io.File from, StorageFile to, byte[] buffer, java.lang.String[] filter)
-
copyFile
public static boolean copyFile(WritableStorageFactory storageFactory, java.io.File from, StorageFile to)
-
copyFile
public static boolean copyFile(WritableStorageFactory storageFactory, java.io.File from, StorageFile to, byte[] buf)
-
copyFile
public static boolean copyFile(WritableStorageFactory storageFactory, StorageFile from, StorageFile to)
-
stripProtocolFromFileName
public static java.lang.String stripProtocolFromFileName(java.lang.String originalName)
Remove the leading 'file://' protocol from a filename which has been expressed as an URL. If the filename is not an URL, then nothing is done. Otherwise, an URL like 'file:///tmp/foo.txt' is transformed into the legal file name '/tmp/foo.txt'.
-
limitAccessToOwner
public static void limitAccessToOwner(java.io.File file) throws java.io.IOExceptionUse when creating new files. If running on Unix, limit read and write permissions on
fileto owner ifderby.storage.useDefaultFilePermissions == false.If the property is not specified, we use restrictive permissions anyway iff running with the server server started from the command line.
On Unix, this is equivalent to running with umask 0077.
On Windows, with FAT/FAT32, we lose, since the fs does not support permissions, only a read-only flag.
On Windows, with NTFS with ACLs, if running with Java 7 or higher, we limit access also for Windows using the new
java.nio.file.attributepackage.When restricted file access is enabled (either explicitly or by default) errors are handled like this: When running on JDK 7 or higher, and the file system can be accessed either via a PosixFileAttributeView or via an AclFileAttributeView, any IOException reported when trying to restrict the permissions will also be thrown by this method. In all other cases, it will do its best to limit the permissions using the
java.io.Filemethods (setReadable(),setWritable(),setExecutable()), but it won't throw any exceptions if the permissions cannot be set that way.- Parameters:
file- assumed to be just created- Throws:
java.io.IOException- if an I/O error happens when trying to change the file permissions
-
-
DataMelt 3.0 © DataMelt by jWork.ORG