Class FileUtils
- java.lang.Object
- 
- com.ibm.wsspi.kernel.service.utils.FileUtils
 
- 
 public class FileUtils extends java.lang.ObjectA set of utilities for working with Files
- 
- 
Constructor SummaryConstructors Constructor Description FileUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanensureDirExists(java.io.File dir)CallsFile.mkdirs()andFile.exists()on the specifiedtargetstatic booleanfileCanRead(java.io.File target)Execute theFile.canRead()from within aPrivilegedAction.static booleanfileCanWrite(java.io.File target)Execute theFile.canWrite()from within aPrivilegedAction.static java.lang.BooleanfileCreate(java.io.File target)CallsFile.createNewFile()on the specifiedtargetstatic booleanfileDelete(java.io.File file)Delete filestatic booleanfileExists(java.io.File target)Execute theFile.exists()from within aPrivilegedAction.static booleanfileIsDirectory(java.io.File target)Execute theFile.isDirectory()from within aPrivilegedAction.static booleanfileIsFile(java.io.File target)Execute theFile.isFile()from within aPrivilegedAction.static longfileLastModified(java.io.File target)Execute theFile.lastModified()from within aPrivilegedAction.static longfileLength(java.io.File target)Execute theFile.length()from within aPrivilegedAction.static booleanfileMkDirs(java.io.File target)CallsFile.mkdirs()on the specifiedtargetfrom within aPrivilegedAction.static java.io.FileOutputStreamgetFileOutputStream(java.io.File target)Create a newFileOutputStreamfor the file within aPrivilegedAction.static java.io.InputStreamgetInputStream(java.io.File target)Create a newInputStreamfor the file within aPrivilegedAction.static java.lang.String[]list(java.io.File target)Execute theFile.list()from within aPrivilegedAction.static java.io.File[]listFiles(java.io.File target)Execute theFile.listFiles()from within aPrivilegedAction.static booleansetUserReadWriteOnly(java.io.File file)Set the file permissions of the file to be user rw only.static booleantryToClose(java.io.Closeable closeable)Close the closeable object
 
- 
- 
- 
Method Detail- 
fileIsFilepublic static boolean fileIsFile(java.io.File target) Execute theFile.isFile()from within aPrivilegedAction.- Parameters:
- f-
- Returns:
 
 - 
fileIsDirectorypublic static boolean fileIsDirectory(java.io.File target) Execute theFile.isDirectory()from within aPrivilegedAction.- Parameters:
- f-
- Returns:
 
 - 
fileExistspublic static boolean fileExists(java.io.File target) Execute theFile.exists()from within aPrivilegedAction.- Parameters:
- target-
- Returns:
 
 - 
fileLengthpublic static long fileLength(java.io.File target) Execute theFile.length()from within aPrivilegedAction.- Parameters:
- target-
- Returns:
 
 - 
listFilespublic static java.io.File[] listFiles(java.io.File target) Execute theFile.listFiles()from within aPrivilegedAction.- Parameters:
- f-
- Returns:
 
 - 
listpublic static java.lang.String[] list(java.io.File target) Execute theFile.list()from within aPrivilegedAction.- Parameters:
- f-
- Returns:
 
 - 
getInputStreampublic static java.io.InputStream getInputStream(java.io.File target) throws java.io.FileNotFoundExceptionCreate a newInputStreamfor the file within aPrivilegedAction.- Throws:
- java.io.FileNotFoundException
 
 - 
getFileOutputStreampublic static java.io.FileOutputStream getFileOutputStream(java.io.File target) throws java.io.FileNotFoundExceptionCreate a newFileOutputStreamfor the file within aPrivilegedAction.- Throws:
- java.io.FileNotFoundException
 
 - 
fileLastModifiedpublic static long fileLastModified(java.io.File target) Execute theFile.lastModified()from within aPrivilegedAction.- Parameters:
- target- The file to get the last modified for
- Returns:
- The last modified for the file
 
 - 
fileCanReadpublic static boolean fileCanRead(java.io.File target) Execute theFile.canRead()from within aPrivilegedAction.- Parameters:
- target- The file to test if it can be read
- Returns:
- trueif the file can be read
 
 - 
fileCanWritepublic static boolean fileCanWrite(java.io.File target) Execute theFile.canWrite()from within aPrivilegedAction.- Parameters:
- target- The file to test if it can be written
- Returns:
- trueif the file can be written
 
 - 
fileMkDirspublic static boolean fileMkDirs(java.io.File target) CallsFile.mkdirs()on the specifiedtargetfrom within aPrivilegedAction.- Parameters:
- target- The tarket to make a directory for
- Returns:
- trueif this succeeded.
 
 - 
fileDeletepublic static boolean fileDelete(java.io.File file) Delete file- Returns:
- trueif file was deleted
 
 - 
ensureDirExistspublic static boolean ensureDirExists(java.io.File dir) CallsFile.mkdirs()andFile.exists()on the specifiedtarget- Parameters:
- target- The target to check for existence or to create if it doesn't exist
- Returns:
- trueif either call succeeded.
 
 - 
tryToClosepublic static boolean tryToClose(java.io.Closeable closeable) Close the closeable object- Parameters:
- closeable-
 
 - 
setUserReadWriteOnlypublic static boolean setUserReadWriteOnly(java.io.File file) Set the file permissions of the file to be user rw only.This is a best effort attempt as Windows does NOT play nicely with file perms. - Parameters:
- an- existing File
 
 - 
fileCreatepublic static java.lang.Boolean fileCreate(java.io.File target) throws java.io.IOExceptionCallsFile.createNewFile()on the specifiedtarget- Parameters:
- target- The target to create if it doesn't exist
- Returns:
- trueif call succeeded.
- Throws:
- java.io.IOException
 
 
- 
 
-