lumis.util
Class FileUtil

Package class diagram package FileUtil
java.lang.Object
  extended by lumis.util.FileUtil

@StableMinor(version="4.1",
             sinceVersion="4.0")
public class FileUtil
extends Object

Utility methods for file manipulation.

Since:
4.0.0

Constructor Summary
FileUtil()
           
 
Method Summary
static boolean compareFiles(File file1, File file2)
          Compare two files.
static boolean compareStream(InputStream in1, InputStream in2)
           
static void copyFile(File srcFile, File destFile)
          Copies a file.
static void copyStream(InputStream in, OutputStream out)
           
static File createDir(String dirPath, boolean clearIfExists)
           
static File createFile(String filePath)
           
static FileOutputStream createFileOutputStream(String filePath)
           
static boolean deleteDir(File dir)
           
static boolean deleteDir(File dir, boolean deleteFiles)
           
static boolean deleteDir(String dir)
           
static boolean deleteDir(String dir, boolean deleteFiles)
           
static boolean deleteFile(String filePath)
           
static void extractZip(ZipInputStream zipInput, File destDir)
          Extracts a zip input stream into a directory.
static boolean fileExists(String filePath)
           
static boolean move(String sourcePath, String targetPath)
           
static void zipDir(File dirToZip, String dirZipRelativePath, ZipOutputStream zos)
          Zips a directory recursively into the given zip output stream.
static void zipDir(File dirToZip, ZipOutputStream zos)
          Zips a directory recursively into the given zip output stream.
 
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

move

public static boolean move(String sourcePath,
                           String targetPath)

createFileOutputStream

public static FileOutputStream createFileOutputStream(String filePath)
                                               throws PortalException
Throws:
PortalException

createDir

public static File createDir(String dirPath,
                             boolean clearIfExists)
                      throws PortalException
Throws:
PortalException

createFile

public static File createFile(String filePath)
                       throws PortalException
Throws:
PortalException

fileExists

public static boolean fileExists(String filePath)

deleteDir

public static boolean deleteDir(String dir)

deleteFile

public static boolean deleteFile(String filePath)

deleteDir

public static boolean deleteDir(String dir,
                                boolean deleteFiles)

deleteDir

public static boolean deleteDir(File dir)

deleteDir

public static boolean deleteDir(File dir,
                                boolean deleteFiles)

copyFile

public static void copyFile(File srcFile,
                            File destFile)
                     throws IOException
Copies a file.

Throws:
IOException - if an I/O error occurs.

copyStream

public static void copyStream(InputStream in,
                              OutputStream out)
                       throws IOException
Throws:
IOException

compareFiles

public static boolean compareFiles(File file1,
                                   File file2)
                            throws IOException
Compare two files.

Parameters:
file1 -
file2 -
Returns:
true, if the files' contents are identical.
Throws:
IOException

compareStream

public static boolean compareStream(InputStream in1,
                                    InputStream in2)
                             throws IOException
Throws:
IOException

extractZip

public static void extractZip(ZipInputStream zipInput,
                              File destDir)
                       throws IOException
Extracts a zip input stream into a directory.

Parameters:
zipInput - the zip input stream.
destDir - the directory where the zip is to be extracted.
Throws:
IOException - if an I/O error occurs.
Since:
4.0.7

zipDir

public static void zipDir(File dirToZip,
                          ZipOutputStream zos)
                   throws IOException
Zips a directory recursively into the given zip output stream. The files in the given directory will be in the zip root.

Parameters:
dirToZip - the dir to zip.
zos - the zip output stream.
Throws:
IOException - if an I/O error occurs.
Since:
4.0.7

zipDir

public static void zipDir(File dirToZip,
                          String dirZipRelativePath,
                          ZipOutputStream zos)
                   throws IOException
Zips a directory recursively into the given zip output stream.

Parameters:
dirToZip - the dir to zip.
dirZipRelativePath - the path for the dir inside the generated zip file. If it refers to the zip root, its value must be an empty string; or it must end with slash if it refers to a directory inside the zip.
zos - the zip output stream.
Throws:
IOException - if an I/O error occurs.
Since:
4.0.7


Lumisportal  4.1.0.071221 - Copyright © 2001-2007, Lumis. All Rights Reserved.