net.sourceforge.pebble.util
Class FileUtils

java.lang.Object
  extended by net.sourceforge.pebble.util.FileUtils

public final class FileUtils
extends java.lang.Object

A collection of utility methods for manipulating files.

Author:
Simon Brown

Constructor Summary
FileUtils()
           
 
Method Summary
static void copyFile(java.io.File source, java.io.File destination)
          Copies a file.
static void deleteFile(java.io.File directory)
          Deletes a file, including all files and sub-directories if the specified file is a directory.
static java.lang.String getContentType(java.lang.String name)
          Gets the content type for the specified filename.
static boolean underneathRoot(java.io.File root, java.io.File file)
          Determines whether a given file is underneath a given root.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtils

public FileUtils()
Method Detail

underneathRoot

public static boolean underneathRoot(java.io.File root,
                                     java.io.File file)
Determines whether a given file is underneath a given root.

Parameters:
root - the root directory
file - the file to test
Returns:
true if the file is underneath the root, false otherwise or if this can not be determined because of security constraints in place

deleteFile

public static void deleteFile(java.io.File directory)
Deletes a file, including all files and sub-directories if the specified file is a directory.

Parameters:
directory - a File instance representing the directory to delete

copyFile

public static void copyFile(java.io.File source,
                            java.io.File destination)
                     throws java.io.IOException
Copies a file.

Parameters:
source - the source File
destination - the destination File
Throws:
java.io.IOException

getContentType

public static java.lang.String getContentType(java.lang.String name)
Gets the content type for the specified filename.

Parameters:
name - the name of a file
Returns:
a MIME type, or application/octet-stream if one can't be found


Copyright © 2003-2006, Simon Brown. All Rights Reserved.