edu.northwestern.at.utils
Class FileNameUtils

java.lang.Object
  extended by edu.northwestern.at.utils.FileNameUtils

public class FileNameUtils
extends java.lang.Object

File name utilities.

This static class provides various utility methods for manipulating file and directory names.


Field Summary
static MimeTypeMapper mimeTypeMapper
          Static mime type mapper.
 
Method Summary
static boolean fileExists(java.lang.String fileName)
          Checks if a file exists.
static java.lang.String getContentTypeFor(java.lang.String fileName)
          Get MIME type for a filename.
static java.lang.String getFileExtension(java.lang.String fileName, boolean keepPeriod)
          Get file extension from file name.
static java.lang.String stripPathName(java.lang.String fileName)
          Strips path from a file name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mimeTypeMapper

public static MimeTypeMapper mimeTypeMapper
Static mime type mapper.

Method Detail

stripPathName

public static java.lang.String stripPathName(java.lang.String fileName)
Strips path from a file name.

Parameters:
fileName - File name with possible path.
Returns:
File name stripped of path.

getFileExtension

public static java.lang.String getFileExtension(java.lang.String fileName,
                                                boolean keepPeriod)
Get file extension from file name.

Parameters:
fileName - The file name whose extension is wanted.
keepPeriod - Keep the period in the extension.
Returns:
The extension, if any, with the optional leading period.

getContentTypeFor

public static java.lang.String getContentTypeFor(java.lang.String fileName)
Get MIME type for a filename.

Parameters:
fileName - Name of file for which mime type is desired.
Returns:
The mime type, e.g., "text/plain".

When the file name's extension is not found in the mime types hash table, a mime type of "application/octet-stream" is returned.


fileExists

public static boolean fileExists(java.lang.String fileName)
Checks if a file exists.

Parameters:
fileName - The file name to check for existence.
Returns:
True if file exists.