org.apache.tools.ant.util
Class FileUtils

java.lang.Object
  |
  +--org.apache.tools.ant.util.FileUtils

public class FileUtils
extends java.lang.Object

This class also encapsulates methods which allow Files to be refered to using abstract path names which are translated to native system file paths at runtime as well as copying files or setting there last modification time.

Author:
duncan@x180.com, Conor MacNeill, Stefan Bodewig

Constructor Summary
protected FileUtils()
          Empty constructor.
 
Method Summary
 void copyFile(java.io.File sourceFile, java.io.File destFile)
          Convienence method to copy a file from a source to a destination.
 void copyFile(java.io.File sourceFile, java.io.File destFile, FilterSetCollection filters)
          Convienence method to copy a file from a source to a destination specifying if token filtering must be used.
 void copyFile(java.io.File sourceFile, java.io.File destFile, FilterSetCollection filters, boolean overwrite)
          Convienence method to copy a file from a source to a destination specifying if token filtering must be used and if source files may overwrite newer destination files.
 void copyFile(java.io.File sourceFile, java.io.File destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified)
          Convienence method to copy a file from a source to a destination specifying if token filtering must be used, if source files may overwrite newer destination files and the last modified time of destFile file should be made equal to the last modified time of sourceFile.
 void copyFile(java.lang.String sourceFile, java.lang.String destFile)
          Convienence method to copy a file from a source to a destination.
 void copyFile(java.lang.String sourceFile, java.lang.String destFile, FilterSetCollection filters)
          Convienence method to copy a file from a source to a destination specifying if token filtering must be used.
 void copyFile(java.lang.String sourceFile, java.lang.String destFile, FilterSetCollection filters, boolean overwrite)
          Convienence method to copy a file from a source to a destination specifying if token filtering must be used and if source files may overwrite newer destination files.
 void copyFile(java.lang.String sourceFile, java.lang.String destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified)
          Convienence method to copy a file from a source to a destination specifying if token filtering must be used, if source files may overwrite newer destination files and the last modified time of destFile file should be made equal to the last modified time of sourceFile.
protected  java.lang.reflect.Method getSetLastModified()
          see whether we have a setLastModified method in File and return it.
static FileUtils newFileUtils()
          Factory method.
 java.io.File normalize(java.lang.String path)
          "normalize" the given absolute path.
 java.io.File resolveFile(java.io.File file, java.lang.String filename)
          Interpret the filename as a file relative to the given file - unless the filename already represents an absolute filename.
 void setFileLastModified(java.io.File file, long time)
          Calls File.setLastModified(long time) in a Java 1.1 compatible way.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtils

protected FileUtils()
Empty constructor.
Method Detail

newFileUtils

public static FileUtils newFileUtils()
Factory method.

copyFile

public void copyFile(java.lang.String sourceFile,
                     java.lang.String destFile)
              throws java.io.IOException
Convienence method to copy a file from a source to a destination. No filtering is performed.
Throws:
java.io.IOException -  

copyFile

public void copyFile(java.lang.String sourceFile,
                     java.lang.String destFile,
                     FilterSetCollection filters)
              throws java.io.IOException
Convienence method to copy a file from a source to a destination specifying if token filtering must be used.
Throws:
java.io.IOException -  

copyFile

public void copyFile(java.lang.String sourceFile,
                     java.lang.String destFile,
                     FilterSetCollection filters,
                     boolean overwrite)
              throws java.io.IOException
Convienence method to copy a file from a source to a destination specifying if token filtering must be used and if source files may overwrite newer destination files.
Throws:
java.io.IOException -  

copyFile

public void copyFile(java.lang.String sourceFile,
                     java.lang.String destFile,
                     FilterSetCollection filters,
                     boolean overwrite,
                     boolean preserveLastModified)
              throws java.io.IOException
Convienence method to copy a file from a source to a destination specifying if token filtering must be used, if source files may overwrite newer destination files and the last modified time of destFile file should be made equal to the last modified time of sourceFile.
Throws:
java.io.IOException -  

copyFile

public void copyFile(java.io.File sourceFile,
                     java.io.File destFile)
              throws java.io.IOException
Convienence method to copy a file from a source to a destination. No filtering is performed.
Throws:
java.io.IOException -  

copyFile

public void copyFile(java.io.File sourceFile,
                     java.io.File destFile,
                     FilterSetCollection filters)
              throws java.io.IOException
Convienence method to copy a file from a source to a destination specifying if token filtering must be used.
Throws:
java.io.IOException -  

copyFile

public void copyFile(java.io.File sourceFile,
                     java.io.File destFile,
                     FilterSetCollection filters,
                     boolean overwrite)
              throws java.io.IOException
Convienence method to copy a file from a source to a destination specifying if token filtering must be used and if source files may overwrite newer destination files.
Throws:
java.io.IOException -  

copyFile

public void copyFile(java.io.File sourceFile,
                     java.io.File destFile,
                     FilterSetCollection filters,
                     boolean overwrite,
                     boolean preserveLastModified)
              throws java.io.IOException
Convienence method to copy a file from a source to a destination specifying if token filtering must be used, if source files may overwrite newer destination files and the last modified time of destFile file should be made equal to the last modified time of sourceFile.
Throws:
java.io.IOException -  

getSetLastModified

protected final java.lang.reflect.Method getSetLastModified()
see whether we have a setLastModified method in File and return it.

setFileLastModified

public void setFileLastModified(java.io.File file,
                                long time)
                         throws BuildException
Calls File.setLastModified(long time) in a Java 1.1 compatible way.

resolveFile

public java.io.File resolveFile(java.io.File file,
                                java.lang.String filename)
Interpret the filename as a file relative to the given file - unless the filename already represents an absolute filename.
Parameters:
file - the "reference" file for relative paths. This instance must be an absolute file and must not contain "./" or "../" sequences (same for \ instead of /).
filename - a file name
Returns:
an absolute file that doesn't contain "./" or "../" sequences and uses the correct separator for the current platform.

normalize

public java.io.File normalize(java.lang.String path)
"normalize" the given absolute path.

This includes:



Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.