org.leafcutter.core
Class FileHelper

java.lang.Object
  extended by org.leafcutter.core.FileHelper

public class FileHelper
extends java.lang.Object

Class containing utility methods for manipulating files.


Constructor Summary
FileHelper()
           
 
Method Summary
static void delete(java.io.File f)
          Delete a file.
static java.io.File getCanonicalFile(java.io.File f)
           
static java.util.ArrayList getFiles(java.lang.String declaration)
          Get all files in a fileset or dirset.
static java.util.ArrayList getFiles(java.lang.String declaration, java.lang.Object arg)
          Get all files in a fileset or dirset, using one variable argument
static java.util.ArrayList getFiles(java.lang.String declaration, java.lang.Object[] args)
          Get all files in a fileset or dirset.
static java.util.ArrayList getFiles(java.lang.String declaration, java.lang.Object arg1, java.lang.Object arg2)
          Get all files in a fileset or dirset, using two variable arguments
static java.util.ArrayList getFiles(java.lang.String declaration, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          Get all files in a fileset or dirset, using three variable arguments
static java.util.ArrayList getFiles(java.lang.String declaration, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
          Get all files in a fileset or dirset, using four variable arguments
static java.io.File getHomeDir()
          Get the home directory, based on the value of System.getProperty("user.home");
static void mkdir(java.io.File dir)
          Create a new directory.
static void mkdir(java.io.File dir, boolean clean)
          Create a new directory.
static java.lang.String toString(java.io.File f)
           
static void write(java.io.File f, java.lang.String s)
          Write a string to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileHelper

public FileHelper()
Method Detail

getHomeDir

public static java.io.File getHomeDir()
Get the home directory, based on the value of System.getProperty("user.home");

Returns:
the home directory file

getFiles

public static java.util.ArrayList getFiles(java.lang.String declaration)
Get all files in a fileset or dirset.

See Also:
getFiles(String, Object[])

getFiles

public static java.util.ArrayList getFiles(java.lang.String declaration,
                                           java.lang.Object arg)
Get all files in a fileset or dirset, using one variable argument

See Also:
getFiles(String, Object[])

getFiles

public static java.util.ArrayList getFiles(java.lang.String declaration,
                                           java.lang.Object arg1,
                                           java.lang.Object arg2)
Get all files in a fileset or dirset, using two variable arguments

See Also:
getFiles(String, Object[])

getFiles

public static java.util.ArrayList getFiles(java.lang.String declaration,
                                           java.lang.Object arg1,
                                           java.lang.Object arg2,
                                           java.lang.Object arg3)
Get all files in a fileset or dirset, using three variable arguments

See Also:
getFiles(String, Object[])

getFiles

public static java.util.ArrayList getFiles(java.lang.String declaration,
                                           java.lang.Object arg1,
                                           java.lang.Object arg2,
                                           java.lang.Object arg3,
                                           java.lang.Object arg4)
Get all files in a fileset or dirset, using four variable arguments

See Also:
getFiles(String, Object[])

getFiles

public static java.util.ArrayList getFiles(java.lang.String declaration,
                                           java.lang.Object[] args)
Get all files in a fileset or dirset. For example (note, backslashes in "name" values are just for Javadoc escape purposes) For example:
 
 ArrayList files = getFiles("fileset dir=${1} casesensitive=false (includes name=**\/*.java)", myDir);
 
 ArrayList dirs = getFiles("dirset dir=source/dir (includes name=**\/data)");   
 
 

Parameters:
declaration -
args - the variable arguments
Returns:
An ArrayList of java.io.File objects

getCanonicalFile

public static java.io.File getCanonicalFile(java.io.File f)
                                     throws TaskRunnerException
Throws:
TaskRunnerException

mkdir

public static void mkdir(java.io.File dir)
Create a new directory. If the directory already exists, it will not be modified.

Parameters:
dir -

mkdir

public static void mkdir(java.io.File dir,
                         boolean clean)
Create a new directory. If clean is set to true and the directory already exists, its contents will be deleted.

Parameters:
dir -
clean -

delete

public static void delete(java.io.File f)
Delete a file. If the file is a directory, all of its contents will be deleted too.

Parameters:
f -

write

public static void write(java.io.File f,
                         java.lang.String s)
Write a string to a file. Any existing file contents will be overwritten.

Parameters:
s -

toString

public static java.lang.String toString(java.io.File f)
                                 throws TaskRunnerException
Throws:
TaskRunnerException