com.ibm.wsspi.kernel.service.utils

Class FileUtils

  1. java.lang.Object
  2. extended bycom.ibm.wsspi.kernel.service.utils.FileUtils

  1. public class FileUtils
  2. extends java.lang.Object
A set of utilities for working with Files

Constructor Summary

Constructor and Description
FileUtils()

Method Summary

Modifier and Type Method and Description
  1. static
  2. boolean
ensureDirExists(java.io.File dir)
Calls File.mkdirs() and File.exists()on the specified target
  1. static
  2. boolean
fileCanRead(java.io.File target)
Execute the File.canRead() from within a PrivilegedAction.
  1. static
  2. boolean
fileCanWrite(java.io.File target)
Execute the File.canWrite() from within a PrivilegedAction.
  1. static
  2. boolean
fileDelete(java.io.File file)
Delete file
  1. static
  2. boolean
fileExists(java.io.File target)
Execute the File.exists() from within a PrivilegedAction.
  1. static
  2. boolean
fileIsDirectory(java.io.File target)
Execute the File.isDirectory() from within a PrivilegedAction.
  1. static
  2. boolean
fileIsFile(java.io.File target)
Execute the File.isFile() from within a PrivilegedAction.
  1. static
  2. long
fileLastModified(java.io.File target)
Execute the File.lastModified() from within a PrivilegedAction.
  1. static
  2. long
fileLength(java.io.File target)
Execute the File.length() from within a PrivilegedAction.
  1. static
  2. boolean
fileMkDirs(java.io.File target)
Calls File.mkdirs()on the specified target from within a PrivilegedAction.
  1. static
  2. java.io.InputStream
getInputStream(java.io.File target)
Create a new InputStream for the file within a PrivilegedAction.
  1. static
  2. java.lang.String[]
list(java.io.File target)
Execute the File.list() from within a PrivilegedAction.
  1. static
  2. java.io.File[]
listFiles(java.io.File target)
Execute the File.listFiles() from within a PrivilegedAction.
  1. static
  2. boolean
setUserReadWriteOnly(java.io.File file)
Set the file permissions of the file to be user rw only.
  1. static
  2. boolean
tryToClose(java.io.Closeable closeable)
Close the closeable object
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

FileUtils

  1. public FileUtils()

Method Detail

fileIsFile

  1. public static boolean fileIsFile( java.io.File target)
Execute the File.isFile() from within a PrivilegedAction.
Returns:

fileIsDirectory

  1. public static boolean fileIsDirectory( java.io.File target)
Execute the File.isDirectory() from within a PrivilegedAction.
Returns:

fileExists

  1. public static boolean fileExists( java.io.File target)
Execute the File.exists() from within a PrivilegedAction.
Parameters:
target -
Returns:

fileLength

  1. public static long fileLength(java.io.File target)
Execute the File.length() from within a PrivilegedAction.
Parameters:
target -
Returns:

listFiles

  1. public static java.io.File[] listFiles( java.io.File target)
Execute the File.listFiles() from within a PrivilegedAction.
Returns:

list

  1. public static java.lang.String[] list( java.io.File target)
Execute the File.list() from within a PrivilegedAction.
Returns:

getInputStream

  1. public static java.io.InputStream getInputStream( java.io.File target)
  2. throws java.io.FileNotFoundException
Create a new InputStream for the file within a PrivilegedAction.
Throws:
java.io.FileNotFoundException

fileLastModified

  1. public static long fileLastModified( java.io.File target)
Execute the File.lastModified() from within a PrivilegedAction.
Parameters:
target - The file to get the last modified for
Returns:
The last modified for the file

fileCanRead

  1. public static boolean fileCanRead( java.io.File target)
Execute the File.canRead() from within a PrivilegedAction.
Parameters:
target - The file to test if it can be read
Returns:
true if the file can be read

fileCanWrite

  1. public static boolean fileCanWrite( java.io.File target)
Execute the File.canWrite() from within a PrivilegedAction.
Parameters:
target - The file to test if it can be written
Returns:
true if the file can be written

fileMkDirs

  1. public static boolean fileMkDirs( java.io.File target)
Calls File.mkdirs() on the specified target from within a PrivilegedAction.
Parameters:
target - The tarket to make a directory for
Returns:
true if this succeeded.

fileDelete

  1. public static boolean fileDelete( java.io.File file)
Delete file
Returns:
true if file was deleted

ensureDirExists

  1. public static boolean ensureDirExists( java.io.File dir)
Calls File.mkdirs() and File.exists() on the specified target
Returns:
true if either call succeeded.

tryToClose

  1. public static boolean tryToClose( java.io.Closeable closeable)
Close the closeable object
Parameters:
closeable -

setUserReadWriteOnly

  1. public 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.