jgnash.util
Class FileUtils

java.lang.Object
  extended by jgnash.util.FileUtils

public final class FileUtils
extends java.lang.Object

File utilities

Version:
$Id$
Author:
Craig Cavanaugh

Field Summary
private static java.lang.String FILEEXTREGEX
          Regular expression for returning the file extension
 
Constructor Summary
private FileUtils()
           
 
Method Summary
static void compressFile(java.io.File source, java.io.File destination)
           
static boolean copyFile(java.io.File src, java.io.File dst)
          Make a copy of a file given a source and destination.
static boolean fileHasExtension(java.lang.String fileName)
          Determine if the supplied file name has an extension
static java.util.List<java.io.File> getDirectoryListing(java.io.File directory, java.lang.String pattern)
          Returns a sorted list of files in a specified directory that match a DOS style wildcard search pattern.
static java.lang.String getFileExtension(java.lang.String fileName)
           
static boolean isFileLocked(java.lang.String fileName)
          Determines if a file has been locked for use.
static java.lang.String stripFileExtension(java.lang.String fileName)
          Strips the extension off of the supplied filename.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILEEXTREGEX

private static final java.lang.String FILEEXTREGEX
Regular expression for returning the file extension

See Also:
Constant Field Values
Constructor Detail

FileUtils

private FileUtils()
Method Detail

isFileLocked

public static boolean isFileLocked(java.lang.String fileName)
                            throws java.io.FileNotFoundException
Determines if a file has been locked for use. The lock check is performed at the OS level.

Parameters:
fileName - file name to check for locked state
Returns:
true if the file is locked at the OS level.
Throws:
java.io.FileNotFoundException - thrown if file does not exist

stripFileExtension

public static java.lang.String stripFileExtension(java.lang.String fileName)
Strips the extension off of the supplied filename. If the supplied filename does not contain an extension then the original is returned

Parameters:
fileName - filename to strip the extension off
Returns:
filename with extension removed

fileHasExtension

public static boolean fileHasExtension(java.lang.String fileName)
Determine if the supplied file name has an extension

Parameters:
fileName - filename to check
Returns:
true if supplied file has an extension

getFileExtension

public static java.lang.String getFileExtension(java.lang.String fileName)

copyFile

public static boolean copyFile(java.io.File src,
                               java.io.File dst)
                        throws java.io.FileNotFoundException
Make a copy of a file given a source and destination.

Parameters:
src - Source file
dst - Destination file
Returns:
true is the copy was successful
Throws:
java.io.FileNotFoundException - thrown if the src file is not found or if the dst file is not a valid filename

compressFile

public static void compressFile(java.io.File source,
                                java.io.File destination)

getDirectoryListing

public static java.util.List<java.io.File> getDirectoryListing(java.io.File directory,
                                                               java.lang.String pattern)
Returns a sorted list of files in a specified directory that match a DOS style wildcard search pattern.

Parameters:
directory - base directory for the search
pattern - DOS search pattern
Returns:
a List of matching Files. The list will be empty if no matches are found or if the directory is not valid.