Class FileUtils
java.lang.Object
com.ibm.wsspi.kernel.service.utils.FileUtils
A set of utilities for working with Files
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanensureDirExists(File dir) static booleanfileCanRead(File target) Execute theFile.canRead()from within aPrivilegedAction.static booleanfileCanWrite(File target) Execute theFile.canWrite()from within aPrivilegedAction.static BooleanfileCreate(File target) CallsFile.createNewFile()on the specifiedtargetstatic booleanfileDelete(File file) Delete filestatic booleanfileExists(File target) Execute theFile.exists()from within aPrivilegedAction.static booleanfileIsDirectory(File target) Execute theFile.isDirectory()from within aPrivilegedAction.static booleanfileIsFile(File target) Execute theFile.isFile()from within aPrivilegedAction.static longfileLastModified(File target) Execute theFile.lastModified()from within aPrivilegedAction.static longfileLength(File target) Execute theFile.length()from within aPrivilegedAction.static booleanstatic booleanfileMkDirs(File target) static FileOutputStreamgetFileOutputStream(File target) Create a newFileOutputStreamfor the file within aPrivilegedAction.static InputStreamgetInputStream(File target) Create a newInputStreamfor the file within aPrivilegedAction.static String[]Execute theFile.list()from within aPrivilegedAction.static File[]Execute theFile.listFiles()from within aPrivilegedAction.static booleansetUserReadWriteOnly(File file) Set the file permissions of the file to be user rw only.static booleantryToClose(Closeable closeable) Close the closeable object
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
fileIsFile
Execute theFile.isFile()from within aPrivilegedAction.- Parameters:
f-- Returns:
-
fileIsDirectory
Execute theFile.isDirectory()from within aPrivilegedAction.- Parameters:
f-- Returns:
-
fileExists
Execute theFile.exists()from within aPrivilegedAction.- Parameters:
target-- Returns:
-
fileLength
Execute theFile.length()from within aPrivilegedAction.- Parameters:
target-- Returns:
-
listFiles
Execute theFile.listFiles()from within aPrivilegedAction.- Parameters:
f-- Returns:
-
list
Execute theFile.list()from within aPrivilegedAction.- Parameters:
f-- Returns:
-
getInputStream
Create a newInputStreamfor the file within aPrivilegedAction.- Throws:
FileNotFoundException
-
getFileOutputStream
Create a newFileOutputStreamfor the file within aPrivilegedAction.- Throws:
FileNotFoundException
-
fileLastModified
Execute theFile.lastModified()from within aPrivilegedAction.- Parameters:
target- The file to get the last modified for- Returns:
- The last modified for the file
-
fileCanRead
Execute theFile.canRead()from within aPrivilegedAction.- Parameters:
target- The file to test if it can be read- Returns:
trueif the file can be read
-
fileCanWrite
Execute theFile.canWrite()from within aPrivilegedAction.- Parameters:
target- The file to test if it can be written- Returns:
trueif the file can be written
-
fileMkDirs
- Parameters:
target- The tarket to make a directory for- Returns:
trueif this succeeded.
-
fileMkDir
- Parameters:
target- The tarket to make a directory for- Returns:
trueif this succeeded.
-
fileDelete
Delete file- Returns:
trueif file was deleted
-
ensureDirExists
- Parameters:
target- The target to check for existence or to create if it doesn't exist- Returns:
trueif either call succeeded.
-
tryToClose
Close the closeable object- Parameters:
closeable-
-
setUserReadWriteOnly
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
-
fileCreate
CallsFile.createNewFile()on the specifiedtarget- Parameters:
target- The target to create if it doesn't exist- Returns:
trueif call succeeded.- Throws:
IOException
-