Liferay 6.2-ce-ga5

com.liferay.portal.kernel.util
Class FileUtil

java.lang.Object
  extended by com.liferay.portal.kernel.util.FileUtil

public class FileUtil
extends Object


Constructor Summary
FileUtil()
           
 
Method Summary
static String appendParentheticalSuffix(String fileName, String suffix)
           
static void copyDirectory(File source, File destination)
           
static void copyDirectory(String sourceDirName, String destinationDirName)
           
static void copyFile(File source, File destination)
           
static void copyFile(File source, File destination, boolean lazy)
           
static void copyFile(String source, String destination)
           
static void copyFile(String source, String destination, boolean lazy)
           
static File createTempFile()
           
static File createTempFile(byte[] bytes)
           
static File createTempFile(InputStream is)
           
static File createTempFile(String extension)
           
static File createTempFile(String prefix, String extension)
           
static String createTempFileName()
           
static String createTempFileName(String extension)
           
static String createTempFileName(String prefix, String extension)
           
static File createTempFolder()
           
static String decodeSafeFileName(String fileName)
           
static boolean delete(File file)
           
static boolean delete(String file)
           
static void deltree(File directory)
           
static void deltree(String directory)
           
static String encodeSafeFileName(String fileName)
           
static boolean exists(File file)
           
static boolean exists(String fileName)
           
static String extractText(InputStream is, String fileName)
          Extract text from an input stream and file name.
static String extractText(InputStream is, String fileName, int maxStringLength)
           
static String[] find(String directory, String includes, String excludes)
           
static String getAbsolutePath(File file)
           
static byte[] getBytes(File file)
           
static byte[] getBytes(InputStream is)
           
static byte[] getBytes(InputStream is, int bufferSize)
           
static byte[] getBytes(InputStream is, int bufferSize, boolean cleanUpStream)
           
static String getExtension(String fileName)
           
static File getFile()
           
static String getMD5Checksum(File file)
           
static String getPath(String fullFileName)
           
static String getShortFileName(String fullFileName)
           
static boolean isAscii(File file)
           
static boolean isSameContent(File file, byte[] bytes, int length)
           
static boolean isSameContent(File file, String s)
           
static String[] listDirs(File file)
           
static String[] listDirs(String fileName)
           
static String[] listFiles(File file)
           
static String[] listFiles(String fileName)
           
static void mkdirs(File file)
           
static void mkdirs(String pathName)
           
static boolean move(File source, File destination)
           
static boolean move(String sourceFileName, String destinationFileName)
           
static String read(File file)
           
static String read(File file, boolean raw)
           
static String read(String fileName)
           
static String replaceSeparator(String fileName)
           
 void setFile(File file)
           
static File[] sortFiles(File[] files)
           
static String stripExtension(String fileName)
           
static List<String> toList(Reader reader)
           
static List<String> toList(String fileName)
           
static Properties toProperties(FileInputStream fis)
           
static Properties toProperties(String fileName)
           
static void touch(File file)
           
static void touch(String fileName)
           
static void unzip(File source, File destination)
           
static void write(File file, byte[] bytes)
           
static void write(File file, byte[] bytes, boolean append)
           
static void write(File file, byte[] bytes, int offset, int length)
           
static void write(File file, byte[] bytes, int offset, int length, boolean append)
           
static void write(File file, InputStream is)
           
static void write(File file, String s)
           
static void write(File file, String s, boolean lazy)
           
static void write(File file, String s, boolean lazy, boolean append)
           
static void write(String fileName, byte[] bytes)
           
static void write(String fileName, InputStream is)
           
static void write(String fileName, String s)
           
static void write(String fileName, String s, boolean lazy)
           
static void write(String fileName, String s, boolean lazy, boolean append)
           
static void write(String pathName, String fileName, String s)
           
static void write(String pathName, String fileName, String s, boolean lazy)
           
static void write(String pathName, String fileName, String s, boolean lazy, boolean append)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtil

public FileUtil()
Method Detail

appendParentheticalSuffix

public static String appendParentheticalSuffix(String fileName,
                                               String suffix)

copyDirectory

public static void copyDirectory(File source,
                                 File destination)
                          throws IOException
Throws:
IOException

copyDirectory

public static void copyDirectory(String sourceDirName,
                                 String destinationDirName)
                          throws IOException
Throws:
IOException

copyFile

public static void copyFile(File source,
                            File destination)
                     throws IOException
Throws:
IOException

copyFile

public static void copyFile(File source,
                            File destination,
                            boolean lazy)
                     throws IOException
Throws:
IOException

copyFile

public static void copyFile(String source,
                            String destination)
                     throws IOException
Throws:
IOException

copyFile

public static void copyFile(String source,
                            String destination,
                            boolean lazy)
                     throws IOException
Throws:
IOException

createTempFile

public static File createTempFile()

createTempFile

public static File createTempFile(byte[] bytes)
                           throws IOException
Throws:
IOException

createTempFile

public static File createTempFile(InputStream is)
                           throws IOException
Throws:
IOException

createTempFile

public static File createTempFile(String extension)

createTempFile

public static File createTempFile(String prefix,
                                  String extension)

createTempFileName

public static String createTempFileName()

createTempFileName

public static String createTempFileName(String extension)

createTempFileName

public static String createTempFileName(String prefix,
                                        String extension)

createTempFolder

public static File createTempFolder()
                             throws IOException
Throws:
IOException

decodeSafeFileName

public static String decodeSafeFileName(String fileName)

delete

public static boolean delete(File file)

delete

public static boolean delete(String file)

deltree

public static void deltree(File directory)

deltree

public static void deltree(String directory)

encodeSafeFileName

public static String encodeSafeFileName(String fileName)

exists

public static boolean exists(File file)

exists

public static boolean exists(String fileName)

extractText

public static String extractText(InputStream is,
                                 String fileName)
Extract text from an input stream and file name.

Parameters:
is - input stream of file
fileName - full name or extension of file (e.g., "Test.doc", ".doc")
Returns:
Extracted text if it is a supported format or an empty string if it is an unsupported format

extractText

public static String extractText(InputStream is,
                                 String fileName,
                                 int maxStringLength)

find

public static String[] find(String directory,
                            String includes,
                            String excludes)

getAbsolutePath

public static String getAbsolutePath(File file)

getBytes

public static byte[] getBytes(File file)
                       throws IOException
Throws:
IOException

getBytes

public static byte[] getBytes(InputStream is)
                       throws IOException
Throws:
IOException

getBytes

public static byte[] getBytes(InputStream is,
                              int bufferSize)
                       throws IOException
Throws:
IOException

getBytes

public static byte[] getBytes(InputStream is,
                              int bufferSize,
                              boolean cleanUpStream)
                       throws IOException
Throws:
IOException

getExtension

public static String getExtension(String fileName)

getFile

public static File getFile()

getMD5Checksum

public static String getMD5Checksum(File file)
                             throws IOException
Throws:
IOException

getPath

public static String getPath(String fullFileName)

getShortFileName

public static String getShortFileName(String fullFileName)

isAscii

public static boolean isAscii(File file)
                       throws IOException
Throws:
IOException

isSameContent

public static boolean isSameContent(File file,
                                    byte[] bytes,
                                    int length)

isSameContent

public static boolean isSameContent(File file,
                                    String s)

listDirs

public static String[] listDirs(File file)

listDirs

public static String[] listDirs(String fileName)

listFiles

public static String[] listFiles(File file)

listFiles

public static String[] listFiles(String fileName)

mkdirs

public static void mkdirs(File file)
                   throws IOException
Throws:
IOException

mkdirs

public static void mkdirs(String pathName)

move

public static boolean move(File source,
                           File destination)

move

public static boolean move(String sourceFileName,
                           String destinationFileName)

read

public static String read(File file)
                   throws IOException
Throws:
IOException

read

public static String read(File file,
                          boolean raw)
                   throws IOException
Throws:
IOException

read

public static String read(String fileName)
                   throws IOException
Throws:
IOException

replaceSeparator

public static String replaceSeparator(String fileName)

sortFiles

public static File[] sortFiles(File[] files)

stripExtension

public static String stripExtension(String fileName)

toList

public static List<String> toList(Reader reader)

toList

public static List<String> toList(String fileName)

toProperties

public static Properties toProperties(FileInputStream fis)

toProperties

public static Properties toProperties(String fileName)

touch

public static void touch(File file)
                  throws IOException
Throws:
IOException

touch

public static void touch(String fileName)
                  throws IOException
Throws:
IOException

unzip

public static void unzip(File source,
                         File destination)

write

public static void write(File file,
                         byte[] bytes)
                  throws IOException
Throws:
IOException

write

public static void write(File file,
                         byte[] bytes,
                         boolean append)
                  throws IOException
Throws:
IOException

write

public static void write(File file,
                         byte[] bytes,
                         int offset,
                         int length)
                  throws IOException
Throws:
IOException

write

public static void write(File file,
                         byte[] bytes,
                         int offset,
                         int length,
                         boolean append)
                  throws IOException
Throws:
IOException

write

public static void write(File file,
                         InputStream is)
                  throws IOException
Throws:
IOException

write

public static void write(File file,
                         String s)
                  throws IOException
Throws:
IOException

write

public static void write(File file,
                         String s,
                         boolean lazy)
                  throws IOException
Throws:
IOException

write

public static void write(File file,
                         String s,
                         boolean lazy,
                         boolean append)
                  throws IOException
Throws:
IOException

write

public static void write(String fileName,
                         byte[] bytes)
                  throws IOException
Throws:
IOException

write

public static void write(String fileName,
                         InputStream is)
                  throws IOException
Throws:
IOException

write

public static void write(String fileName,
                         String s)
                  throws IOException
Throws:
IOException

write

public static void write(String fileName,
                         String s,
                         boolean lazy)
                  throws IOException
Throws:
IOException

write

public static void write(String fileName,
                         String s,
                         boolean lazy,
                         boolean append)
                  throws IOException
Throws:
IOException

write

public static void write(String pathName,
                         String fileName,
                         String s)
                  throws IOException
Throws:
IOException

write

public static void write(String pathName,
                         String fileName,
                         String s,
                         boolean lazy)
                  throws IOException
Throws:
IOException

write

public static void write(String pathName,
                         String fileName,
                         String s,
                         boolean lazy,
                         boolean append)
                  throws IOException
Throws:
IOException

setFile

public void setFile(File file)

Liferay 6.2-ce-ga5