public class FileUtils
extends java.lang.Object
Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
ensureDirExists(java.io.File dir)
Calls
File.mkdirs() and File.exists() on the specified target |
static boolean |
fileCanRead(java.io.File target)
Execute the
File.canRead() from within a PrivilegedAction . |
static boolean |
fileCanWrite(java.io.File target)
Execute the
File.canWrite() from within a PrivilegedAction . |
static java.lang.Boolean |
fileCreate(java.io.File target)
Calls
File.createNewFile() on the specified target |
static boolean |
fileDelete(java.io.File file)
Delete file
|
static boolean |
fileExists(java.io.File target)
Execute the
File.exists() from within a PrivilegedAction . |
static boolean |
fileIsDirectory(java.io.File target)
Execute the
File.isDirectory() from within a PrivilegedAction . |
static boolean |
fileIsFile(java.io.File target)
Execute the
File.isFile() from within a PrivilegedAction . |
static long |
fileLastModified(java.io.File target)
Execute the
File.lastModified() from within a PrivilegedAction . |
static long |
fileLength(java.io.File target)
Execute the
File.length() from within a PrivilegedAction . |
static boolean |
fileMkDirs(java.io.File target)
Calls
File.mkdirs() on the specified target from
within a PrivilegedAction . |
static java.io.FileOutputStream |
getFileOutputStream(java.io.File target)
Create a new
FileOutputStream for the file within a PrivilegedAction . |
static java.io.InputStream |
getInputStream(java.io.File target)
Create a new
InputStream for the file within a PrivilegedAction . |
static java.lang.String[] |
list(java.io.File target)
Execute the
File.list() from within a PrivilegedAction . |
static java.io.File[] |
listFiles(java.io.File target)
Execute the
File.listFiles() from within a PrivilegedAction . |
static boolean |
setUserReadWriteOnly(java.io.File file)
Set the file permissions of the file to be user rw only.
|
static boolean |
tryToClose(java.io.Closeable closeable)
Close the closeable object
|
public static boolean fileIsFile(java.io.File target)
File.isFile()
from within a PrivilegedAction
.f
- public static boolean fileIsDirectory(java.io.File target)
File.isDirectory()
from within a PrivilegedAction
.f
- public static boolean fileExists(java.io.File target)
File.exists()
from within a PrivilegedAction
.target
- public static long fileLength(java.io.File target)
File.length()
from within a PrivilegedAction
.target
- public static java.io.File[] listFiles(java.io.File target)
File.listFiles()
from within a PrivilegedAction
.f
- public static java.lang.String[] list(java.io.File target)
File.list()
from within a PrivilegedAction
.f
- public static java.io.InputStream getInputStream(java.io.File target) throws java.io.FileNotFoundException
InputStream
for the file within a PrivilegedAction
.java.io.FileNotFoundException
public static java.io.FileOutputStream getFileOutputStream(java.io.File target) throws java.io.FileNotFoundException
FileOutputStream
for the file within a PrivilegedAction
.java.io.FileNotFoundException
public static long fileLastModified(java.io.File target)
File.lastModified()
from within a PrivilegedAction
.target
- The file to get the last modified forpublic static boolean fileCanRead(java.io.File target)
File.canRead()
from within a PrivilegedAction
.target
- The file to test if it can be readtrue
if the file can be readpublic static boolean fileCanWrite(java.io.File target)
File.canWrite()
from within a PrivilegedAction
.target
- The file to test if it can be writtentrue
if the file can be writtenpublic static boolean fileMkDirs(java.io.File target)
File.mkdirs()
on the specified target
from
within a PrivilegedAction
.target
- The tarket to make a directory fortrue
if this succeeded.public static boolean fileDelete(java.io.File file)
true
if file was deletedpublic static boolean ensureDirExists(java.io.File dir)
File.mkdirs()
and File.exists()
on the specified target
target
- The target to check for existence or to create if it doesn't existtrue
if either call succeeded.public static boolean tryToClose(java.io.Closeable closeable)
closeable
- public static boolean setUserReadWriteOnly(java.io.File file)
This is a best effort attempt as Windows does NOT play nicely with file perms.
an
- existing Filepublic static java.lang.Boolean fileCreate(java.io.File target) throws java.io.IOException
File.createNewFile()
on the specified target
target
- The target to create if it doesn't existtrue
if call succeeded.java.io.IOException