com.nurelm.util
Class NuFile

java.lang.Object
  extended byjava.io.File
      extended bycom.nurelm.util.NuFile
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class NuFile
extends java.io.File

Extends File and includes the method: isOlderThan().

See Also:
Serialized Form

Field Summary
static int RETURN_PATH_FILE_NAME
          DOCUMENT ME!
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
NuFile(java.lang.String pathFileName)
          Creates a new NuFile object.
 
Method Summary
 java.lang.String extractFileFromPathFileName()
          Returns File only - not the path.
 long getFileSize()
          This method will get the amount of disk space a client is using.
 long getFileSize(java.io.File fileName)
          This method will get the amount of disk space a client is using.
 java.lang.String getFileSizeString()
          This method returns the file size, converted into megs, in the form of a string
 boolean isLink(java.io.File fileName)
          This method will get the absolute and canonical pathname of a file and compares them in order to determine if the file is a link or not.
 boolean isOlderThan(long numHours)
          Returns true if the file is older than the passed-in number of hours.
 boolean newFileName(java.lang.String filename)
           
static java.lang.String stripFileFromPath(java.lang.String pathName)
          Send this method /a/path/to/a/file.txt and get /a/path/to/a/ without the filename at the end.
static java.lang.String verifyPathSlashes(java.lang.String path)
          Verfies that the path has...
 java.lang.String verifyUniqueFileName()
          This method will verify that a given file name and path is unique.
 java.lang.String verifyUniqueFileName(int returnPathFileName)
          DOCUMENT ME!
 
Methods inherited from class java.io.File
canRead, canWrite, compareTo, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RETURN_PATH_FILE_NAME

public static final int RETURN_PATH_FILE_NAME
DOCUMENT ME!

See Also:
Constant Field Values
Constructor Detail

NuFile

public NuFile(java.lang.String pathFileName)
Creates a new NuFile object.

Parameters:
pathFileName - DOCUMENT ME!
Method Detail

isOlderThan

public boolean isOlderThan(long numHours)
                    throws java.lang.SecurityException
Returns true if the file is older than the passed-in number of hours. if the file does not exist, false is returned.

Parameters:
numHours - a long value indicating the age of the file.
Returns:
DOCUMENT ME!
Throws:
java.lang.SecurityException - DOCUMENT ME!

verifyPathSlashes

public static java.lang.String verifyPathSlashes(java.lang.String path)
                                          throws NuFileException
Verfies that the path has... 1. The correct \ or / for the associated operating system. 2. The ending \ or / (the ending slash is added if not present) This method is magically operating system safe. It fixes up the path according to the OS the java VM is running on. What if the path is actually a file? It thinks it is a path - a slash is added to the end of the filename. This is a static method, so just execute NuFile.verifyPathSlashes("/my/path") - you do not need to instantiate a NuFile object and pass in the path in the constructor.

Parameters:
path - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
NuFileException - DOCUMENT ME!

stripFileFromPath

public static java.lang.String stripFileFromPath(java.lang.String pathName)
                                          throws NuFileException
Send this method /a/path/to/a/file.txt and get /a/path/to/a/ without the filename at the end. This method works for both windows and unix.

Parameters:
pathName - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
NuFileException - DOCUMENT ME!

getFileSize

public long getFileSize(java.io.File fileName)
                 throws java.io.IOException
This method will get the amount of disk space a client is using. The method adds the bytes for all files and directories.

Parameters:
fileName - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

getFileSize

public long getFileSize()
                 throws java.io.IOException
This method will get the amount of disk space a client is using. The method adds the bytes for all files and directories.

Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

getFileSizeString

public java.lang.String getFileSizeString()
                                   throws java.io.IOException
This method returns the file size, converted into megs, in the form of a string

Returns:
String the file size in megs
Throws:
java.io.IOException - DOCUMENT ME!

isLink

public boolean isLink(java.io.File fileName)
               throws java.io.IOException
This method will get the absolute and canonical pathname of a file and compares them in order to determine if the file is a link or not. The absolute and canonical pathnames of symbolic links will differ.

Parameters:
fileName - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

verifyUniqueFileName

public java.lang.String verifyUniqueFileName()
                                      throws java.lang.NullPointerException
This method will verify that a given file name and path is unique. If it is not a new file name will be assigned. The new file name will be returned. The Method newFileName is used to find if the file exists.

Returns:
A new fileName String if created, else the original fileName String.
Throws:
java.lang.NullPointerException - DOCUMENT ME!

verifyUniqueFileName

public java.lang.String verifyUniqueFileName(int returnPathFileName)
                                      throws NuFileException
DOCUMENT ME!

Parameters:
returnPathFileName - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
NuFileException - DOCUMENT ME!

newFileName

public boolean newFileName(java.lang.String filename)

extractFileFromPathFileName

public java.lang.String extractFileFromPathFileName()
Returns File only - not the path. Updated 2/7/2002 to use substring. Don't need to Perl it.

Returns:
DOCUMENT ME!