Liferay 6.0.5

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 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(String extension)
           
static String createTempFileName()
           
static String createTempFileName(String extension)
           
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 getAbsolutePath(File file)
           
static byte[] getBytes(File file)
           
static byte[] getBytes(InputStream is)
           
static byte[] getBytes(InputStream is, int bufferSize)
           
static String getExtension(String fileName)
           
static File getFile()
           
static String getPath(String fullFileName)
           
static String getShortFileName(String fullFileName)
           
static boolean isAscii(File file)
           
static String[] listDirs(File file)
           
static String[] listDirs(String fileName)
           
static String[] listFiles(File file)
           
static String[] listFiles(String fileName)
           
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 write(File file, byte[] bytes)
           
static void write(File file, byte[] bytes, int offset, int length)
           
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

copyDirectory

public static void copyDirectory(String sourceDirName,
                                 String destinationDirName)

copyDirectory

public static void copyDirectory(File source,
                                 File destination)

copyFile

public static void copyFile(String source,
                            String destination)

copyFile

public static void copyFile(String source,
                            String destination,
                            boolean lazy)

copyFile

public static void copyFile(File source,
                            File destination)

copyFile

public static void copyFile(File source,
                            File destination,
                            boolean lazy)

createTempFile

public static File createTempFile()

createTempFile

public static File createTempFile(String extension)

createTempFileName

public static String createTempFileName()

createTempFileName

public static String createTempFileName(String extension)

decodeSafeFileName

public static String decodeSafeFileName(String fileName)

delete

public static boolean delete(String file)

delete

public static boolean delete(File file)

deltree

public static void deltree(String directory)

deltree

public static void deltree(File directory)

encodeSafeFileName

public static String encodeSafeFileName(String fileName)

exists

public static boolean exists(String fileName)

exists

public static boolean exists(File file)

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

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

getExtension

public static String getExtension(String fileName)

getFile

public static File getFile()

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

listDirs

public static String[] listDirs(String fileName)

listDirs

public static String[] listDirs(File file)

listFiles

public static String[] listFiles(String fileName)

listFiles

public static String[] listFiles(File file)

mkdirs

public static void mkdirs(String pathName)

move

public static boolean move(String sourceFileName,
                           String destinationFileName)

move

public static boolean move(File source,
                           File destination)

read

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

read

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

read

public static String read(File file,
                          boolean raw)
                   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)

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

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(File file,
                         byte[] bytes)
                  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(String fileName,
                         InputStream is)
                  throws IOException
Throws:
IOException

write

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

setFile

public void setFile(File file)

Liferay 6.0.5