com.arsdigita.util
Class Files

java.lang.Object
  extended bycom.arsdigita.util.Files

public final class Files
extends Object

Commonly used file utilities.

Version:
$Revision: #9 $ $Date: 2004/04/07 $
Author:
Rafael H. Schloming <rhs@mit.edu>, Randy Graebner <randyg@alum.mit.edu>

Field Summary
static int IGNORE_EXISTING
           
static int OVERWRITE
           
static int UPDATE
           
static String versionId
           
 
Method Summary
static void copy(File from, File to)
           
static void copy(File from, File to, int mode)
           
static void delete(File file)
           
static String getPrettySize(File file)
          This will take in a file and return the pretty size in human readable terms.
static String getPrettySize(long longSize)
          This will take in a file and return the pretty size in human readable terms.
static String[] listFilesInTree(File baseDirectory, FilenameFilter filter)
          This recursively builds a list of file paths, including all files that meet the requirements of the file filter, if specified.
static void writeZipFile(OutputStream outputStream, String[] fileList, File baseFile)
          This writes a zip file to the given output stream and has several options for how the file should be written.
static void writeZipFile(String outputFileName, String[] includedFiles, File baseFile)
          A convenience method that will create a FileOutputStream so that the zip file can be written to outputFileName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

OVERWRITE

public static final int OVERWRITE
See Also:
Constant Field Values

UPDATE

public static final int UPDATE
See Also:
Constant Field Values

IGNORE_EXISTING

public static final int IGNORE_EXISTING
See Also:
Constant Field Values
Method Detail

delete

public static void delete(File file)

copy

public static void copy(File from,
                        File to)
                 throws IOException
Throws:
IOException

copy

public static void copy(File from,
                        File to,
                        int mode)
                 throws IOException
Throws:
IOException

writeZipFile

public static void writeZipFile(String outputFileName,
                                String[] includedFiles,
                                File baseFile)
A convenience method that will create a FileOutputStream so that the zip file can be written to outputFileName


writeZipFile

public static void writeZipFile(OutputStream outputStream,
                                String[] fileList,
                                File baseFile)
This writes a zip file to the given output stream and has several options for how the file should be written.

Parameters:
outputStream - The output stream to write the file. This is typically the response output stream if the file is download or a FileOutputStream if it is written to disk.
fileList - A string list of the files to be included in the zip file. The strings are relative to the baseFile or are absolute if the baseFile is null.
baseFile - The file that is used as the base of the zip. This basically allows us to "cd" to the directory and then perform the "zip" from that directory as opposed to doing everything from "/".

listFilesInTree

public static String[] listFilesInTree(File baseDirectory,
                                       FilenameFilter filter)
This recursively builds a list of file paths, including all files that meet the requirements of the file filter, if specified. This does not include the base directory but it does include all other directories


getPrettySize

public static String getPrettySize(File file)
This will take in a file and return the pretty size in human readable terms. Specifically, it will return things like 100kb or 220M instead of just the number of bytes. The formatting is retrieved from the Locale provided by the kernel


getPrettySize

public static String getPrettySize(long longSize)
This will take in a file and return the pretty size in human readable terms. Specifically, it will return things like 100kb or 220M instead of just the number of bytes. The formatting is retrieved from the Locale provided by the kernel



Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC