Package org.exoplatform.commons.utils
Class PrivilegedFileHelper
- java.lang.Object
-
- org.exoplatform.commons.utils.PrivilegedFileHelper
-
public class PrivilegedFileHelper extends Object
- Version:
- $Id: SecurityFileHelper.java 111 2010-11-11 11:11:11Z tolusha $ Class helper need for perform privileged file operations.
- Author:
- Anatoliy Bazko
-
-
Constructor Summary
Constructors Constructor Description PrivilegedFileHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancreateNewFile(File file)Create new file.static FilecreateTempFile(String prefix, String suffix)Create teamporary file in privileged mode.static FilecreateTempFile(String prefix, String suffix, File directory)Create temporary file in privileged mode.static booleandelete(File file)Delete file in privileged mode.static voiddeleteOnExit(File file)Requests in privileged mode that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.static booleanexists(File file)Tests in privileged mode whether the file or directory denoted by this abstract pathname exists.static FileInputStreamfileInputStream(File file)Create FileInputStream in privileged mode.static FileInputStreamfileInputStream(String name)Create FileInputStream in privileged mode.static FileOutputStreamfileOutputStream(File file)Create FileOutputStream in privileged mode.static FileOutputStreamfileOutputStream(File file, boolean append)Create FileOutputStream in privileged mode.static FileOutputStreamfileOutputStream(String name)Create FileOutputStream in privileged mode.static StringgetAbsolutePath(File file)Get file absolute path in privileged mode.static StringgetCanonicalPath(File file)Get file canonical path in privileged mode.static InputStreamgetResourceAsStream(String resource)getResourceAsStream in privileged mode.static booleanisDirectory(File file)Tests in privileged mode whether the file denoted by this abstract pathname is a directory.static longlength(File file)Get file length in privileged mode.static String[]list(File file)Get file's list in privileged mode.static String[]list(File file, FilenameFilter filter)Get file's list in privileged mode.static File[]listFiles(File file)Get file's list in privileged mode.static File[]listFiles(File file, FileFilter filter)Get file's list in privileged mode.static File[]listFiles(File file, FilenameFilter filter)Get file's list in privileged mode.static booleanmkdirs(File file)Creates the directory in privileged mode.static RandomAccessFilerandomAccessFile(File file, String mode)Create RandomAccessFile in privileged mode.static booleanrenameTo(File srcFile, File dstfile)Rename File in privileged mode.static ZipInputStreamzipInputStream(File file)Create FileInputStream in privileged mode.static ZipOutputStreamzipOutputStream(File file)Create ZipOutputStream in privileged mode.
-
-
-
Method Detail
-
getResourceAsStream
public static InputStream getResourceAsStream(String resource) throws FileNotFoundException
getResourceAsStream in privileged mode.- Throws:
FileNotFoundException
-
fileOutputStream
public static FileOutputStream fileOutputStream(File file) throws FileNotFoundException
Create FileOutputStream in privileged mode.- Parameters:
file-- Returns:
- Throws:
FileNotFoundException
-
zipOutputStream
public static ZipOutputStream zipOutputStream(File file) throws FileNotFoundException
Create ZipOutputStream in privileged mode.- Parameters:
file-- Returns:
- Throws:
FileNotFoundException
-
fileOutputStream
public static FileOutputStream fileOutputStream(String name) throws FileNotFoundException
Create FileOutputStream in privileged mode.- Parameters:
name-- Returns:
- Throws:
FileNotFoundException
-
fileOutputStream
public static FileOutputStream fileOutputStream(File file, boolean append) throws FileNotFoundException
Create FileOutputStream in privileged mode.- Parameters:
file-append-- Returns:
- Throws:
FileNotFoundException
-
fileInputStream
public static FileInputStream fileInputStream(File file) throws FileNotFoundException
Create FileInputStream in privileged mode.- Parameters:
file-- Returns:
- Throws:
FileNotFoundException
-
zipInputStream
public static ZipInputStream zipInputStream(File file) throws FileNotFoundException
Create FileInputStream in privileged mode.- Parameters:
file-- Returns:
- Throws:
FileNotFoundException
-
fileInputStream
public static FileInputStream fileInputStream(String name) throws FileNotFoundException
Create FileInputStream in privileged mode.- Parameters:
name-- Returns:
- Throws:
FileNotFoundException
-
createNewFile
public static boolean createNewFile(File file) throws IOException
Create new file.- Parameters:
file-- Returns:
- Throws:
IOException
-
createTempFile
public static File createTempFile(String prefix, String suffix, File directory) throws IllegalArgumentException, IOException
Create temporary file in privileged mode.- Parameters:
prefix-suffix-directory-- Returns:
- Throws:
IllegalArgumentExceptionIOException
-
createTempFile
public static File createTempFile(String prefix, String suffix) throws IllegalArgumentException, IOException
Create teamporary file in privileged mode.- Parameters:
prefix-suffix-- Returns:
- Throws:
IllegalArgumentExceptionIOException
-
randomAccessFile
public static RandomAccessFile randomAccessFile(File file, String mode) throws IllegalArgumentException, IOException
Create RandomAccessFile in privileged mode.- Parameters:
file-mode-- Returns:
- Throws:
IllegalArgumentExceptionIOException
-
length
public static long length(File file)
Get file length in privileged mode.- Parameters:
file-- Returns:
-
deleteOnExit
public static void deleteOnExit(File file)
Requests in privileged mode that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.- Parameters:
file-
-
getAbsolutePath
public static String getAbsolutePath(File file)
Get file absolute path in privileged mode.- Parameters:
file-- Returns:
-
getCanonicalPath
public static String getCanonicalPath(File file) throws IOException
Get file canonical path in privileged mode.- Parameters:
file-- Returns:
- Throws:
IOException
-
delete
public static boolean delete(File file)
Delete file in privileged mode.- Parameters:
file-- Returns:
-
isDirectory
public static boolean isDirectory(File file)
Tests in privileged mode whether the file denoted by this abstract pathname is a directory.- Parameters:
file-- Returns:
-
exists
public static boolean exists(File file)
Tests in privileged mode whether the file or directory denoted by this abstract pathname exists.- Parameters:
file-- Returns:
-
mkdirs
public static boolean mkdirs(File file)
Creates the directory in privileged mode.- Parameters:
file-- Returns:
-
renameTo
public static boolean renameTo(File srcFile, File dstfile)
Rename File in privileged mode.- Parameters:
srcFile-dstfile-- Returns:
-
list
public static String[] list(File file)
Get file's list in privileged mode.- Parameters:
file-- Returns:
-
list
public static String[] list(File file, FilenameFilter filter)
Get file's list in privileged mode.- Parameters:
file-- Returns:
-
listFiles
public static File[] listFiles(File file)
Get file's list in privileged mode.- Parameters:
file-- Returns:
-
listFiles
public static File[] listFiles(File file, FilenameFilter filter)
Get file's list in privileged mode.- Parameters:
file-- Returns:
-
listFiles
public static File[] listFiles(File file, FileFilter filter)
Get file's list in privileged mode.- Parameters:
file-- Returns:
-
-