Java Doc for FileUtils.java in  » Build » ANT » org » apache » tools » ant » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » ANT » org.apache.tools.ant.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.tools.ant.util.FileUtils

FileUtils
public class FileUtils (Code)
This class also encapsulates methods which allow Files to be referred to using abstract path names which are translated to native system file paths at runtime as well as copying files or setting their last modification time.


Field Summary
final static  intBUF_SIZE
    
final public static  longFAT_FILE_TIMESTAMP_GRANULARITY
     The granularity of timestamps under FAT.
final public static  longNTFS_FILE_TIMESTAMP_GRANULARITY
     The granularity of timestamps under the NT File System.
final public static  longUNIX_FILE_TIMESTAMP_GRANULARITY
     The granularity of timestamps under Unix.

Constructor Summary
protected  FileUtils()
     Empty constructor.

Method Summary
public static  voidclose(Writer device)
     Close a Writer without throwing any exception if something went wrong.
public static  voidclose(Reader device)
     Close a stream without throwing any exception if something went wrong.
public static  voidclose(OutputStream device)
     Close a stream without throwing any exception if something went wrong.
public static  voidclose(InputStream device)
     Close a stream without throwing any exception if something went wrong.
public  booleancontentEquals(File f1, File f2)
     Compares the contents of two files.
Parameters:
  f1 - the file whose content is to be compared.
Parameters:
  f2 - the other file whose content is to be compared.
public  booleancontentEquals(File f1, File f2, boolean textfile)
     Compares the contents of two files.
Parameters:
  f1 - the file whose content is to be compared.
Parameters:
  f2 - the other file whose content is to be compared.
Parameters:
  textfile - true if the file is to be treated as a text file anddifferences in kind of line break are to be ignored.
public  voidcopyFile(String sourceFile, String destFile)
     Convenience method to copy a file from a source to a destination.
public  voidcopyFile(String sourceFile, String destFile, FilterSetCollection filters)
     Convenience method to copy a file from a source to a destination specifying if token filtering must be used.
public  voidcopyFile(String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite)
     Convenience 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.
public  voidcopyFile(String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified)
     Convenience 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.
public  voidcopyFile(String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified, String encoding)
     Convenience 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.
public  voidcopyFile(String sourceFile, String destFile, FilterSetCollection filters, Vector filterChains, boolean overwrite, boolean preserveLastModified, String encoding, Project project)
     Convenience method to copy a file from a source to a destination specifying if token filtering must be used, if filter chains 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.
public  voidcopyFile(String sourceFile, String destFile, FilterSetCollection filters, Vector filterChains, boolean overwrite, boolean preserveLastModified, String inputEncoding, String outputEncoding, Project project)
     Convenience method to copy a file from a source to a destination specifying if token filtering must be used, if filter chains 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.
public  voidcopyFile(File sourceFile, File destFile)
     Convenience method to copy a file from a source to a destination.
public  voidcopyFile(File sourceFile, File destFile, FilterSetCollection filters)
     Convenience method to copy a file from a source to a destination specifying if token filtering must be used.
public  voidcopyFile(File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite)
     Convenience 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.
public  voidcopyFile(File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified)
     Convenience 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.
public  voidcopyFile(File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified, String encoding)
     Convenience 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, the last modified time of destFile file should be made equal to the last modified time of sourceFile and which character encoding to assume.
public  voidcopyFile(File sourceFile, File destFile, FilterSetCollection filters, Vector filterChains, boolean overwrite, boolean preserveLastModified, String encoding, Project project)
     Convenience method to copy a file from a source to a destination specifying if token filtering must be used, if filter chains 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.
public  voidcopyFile(File sourceFile, File destFile, FilterSetCollection filters, Vector filterChains, boolean overwrite, boolean preserveLastModified, String inputEncoding, String outputEncoding, Project project)
     Convenience method to copy a file from a source to a destination specifying if token filtering must be used, if filter chains 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.
public  booleancreateNewFile(File f)
     This was originally an emulation of File.createNewFile for JDK 1.1, but it is now implemented using that method (Ant 1.6.3 onwards).

This method has historically not guaranteed that the operation was atomic.

public  booleancreateNewFile(File f, boolean mkdirs)
     Create a new file, optionally creating parent directories.
Parameters:
  f - the file to be created.
Parameters:
  mkdirs - boolean whether to create parent directories.
public  FilecreateTempFile(String prefix, String suffix, File parentDir)
     Create a temporary file in a given directory.

The file denoted by the returned abstract pathname did not exist before this method was invoked, any subsequent invocation of this method will yield a different file name.

The filename is prefixNNNNNsuffix where NNNN is a random number.

This method is different from File.createTempFile() of JDK 1.2 as it doesn't create the file itself.

public  FilecreateTempFile(String prefix, String suffix, File parentDir, boolean deleteOnExit)
     Create a temporary file in a given directory.

The file denoted by the returned abstract pathname did not exist before this method was invoked, any subsequent invocation of this method will yield a different file name.

The filename is prefixNNNNNsuffix where NNNN is a random number.

This method is different from File.createTempFile() of JDK 1.2 as it doesn't create the file itself.

public static  voiddelete(File file)
     Delete the file with File.delete if the argument is not null.
public  String[]dissect(String path)
     Dissect the specified absolute path.
Parameters:
  path - the path to dissect.
public  booleanfileNameEquals(File f1, File f2)
     Compares two filenames.

Unlike java.io.File#equals this method will try to compare the absolute paths and "normalize" the filenames before comparing them.


Parameters:
  f1 - the file whose name is to be compared.
Parameters:
  f2 - the other file whose name is to be compared.
public  StringfromURI(String uri)
     Constructs a file path from a file: URI.

Will be an absolute path if the given URI is absolute.

Swallows '%' that are not followed by two characters, doesn't deal with non-ASCII characters.


Parameters:
  uri - the URI designating a file in the local filesystem.
public  StringgetDefaultEncoding()
     Get the default encoding.
public  longgetFileTimestampGranularity()
     Get the granularity of file timestamps. The choice is made based on OS, which is incorrect--it should really be by filesystem.
public  URLgetFileURL(File file)
     Get the URL for a file taking into account # characters.
Parameters:
  file - the file whose URL representation is required.
public static  FileUtilsgetFileUtils()
     Method to retrieve The FileUtils, which is shared by all users of this method.
public  FilegetParentFile(File f)
     This was originally an emulation of File.getParentFile for JDK 1.1, but it is now implemented using that method (Ant 1.6.3 onwards).
Parameters:
  f - the file whose parent is required.
public static  StringgetPath(List pathStack)
     Gets path from a List of Strings.
Parameters:
  pathStack - List of Strings to be concatedas a path.
public static  StringgetPath(List pathStack, char separatorChar)
     Gets path from a List of Strings.
public static  String[]getPathStack(String path)
     Gets all names of the path as an array of Strings.
public static  StringgetRelativePath(File fromFile, File toFile)
     Calculates the relative path between two files.
public static  booleanisAbsolutePath(String filename)
     Verifies that the specified filename represents an absolute path. Differs from new java.io.File("filename").isAbsolute() in that a path beginning with a double file separator--signifying a Windows UNC--must at minimum match "\\a\b" to be considered an absolute path.
Parameters:
  filename - the filename to be checked.
public static  booleanisContextRelativePath(String filename)
     On DOS and NetWare, the evaluation of certain file specifications is context-dependent.
public  booleanisLeadingPath(File leading, File path)
     Learn whether one path "leads" another.
Parameters:
  leading - The leading path, must not be null, must be absolute.
Parameters:
  path - The path to remove from, must not be null, must be absolute.
public  booleanisSymbolicLink(File parent, String name)
     Checks whether a given file is a symbolic link.

It doesn't really test for symbolic links but whether the canonical and absolute paths of the file are identical--this may lead to false positives on some platforms.


Parameters:
  parent - the parent directory of the file to test
Parameters:
  name - the name of the file to test.
public  booleanisUpToDate(File source, File dest, long granularity)
     Returns true if the source is older than the dest. If the dest file does not exist, then the test returns false; it is implicitly not up do date.
Parameters:
  source - source file (should be the older).
Parameters:
  dest - dest file (should be the newer).
Parameters:
  granularity - an offset added to the source time.
public  booleanisUpToDate(File source, File dest)
     Returns true if the source is older than the dest.
Parameters:
  source - source file (should be the older).
Parameters:
  dest - dest file (should be the newer).
public  booleanisUpToDate(long sourceTime, long destTime, long granularity)
     Compare two timestamps for being up to date using the specified granularity.
Parameters:
  sourceTime - timestamp of source file.
Parameters:
  destTime - timestamp of dest file.
Parameters:
  granularity - os/filesys granularity.
public  booleanisUpToDate(long sourceTime, long destTime)
     Compare two timestamps for being up to date using the current granularity.
Parameters:
  sourceTime - timestamp of source file.
Parameters:
  destTime - timestamp of dest file.
public static  FileUtilsnewFileUtils()
     Factory method.
public  Filenormalize(String path)
     "Normalize" the given absolute path.

This includes:

  • Uppercase the drive letter if there is one.
  • Remove redundant slashes after the drive spec.
  • Resolve all ./, .\, ../ and ..\ sequences.
  • DOS style paths that start with a drive letter will have \ as the separator.
Unlike File.getCanonicalPath this method specifically does not resolve symbolic links.
Parameters:
  path - the path to be normalized.
final public static  StringreadFully(Reader rdr)
     Read from reader till EOF.
Parameters:
  rdr - the reader from which to read.
final public static  StringreadFully(Reader rdr, int bufferSize)
     Read from reader till EOF.
Parameters:
  rdr - the reader from which to read.
Parameters:
  bufferSize - the buffer size to use when reading.
public  StringremoveLeadingPath(File leading, File path)
     Removes a leading path from a second path.
Parameters:
  leading - The leading path, must not be null, must be absolute.
Parameters:
  path - The path to remove from, must not be null, must be absolute.
public  voidrename(File from, File to)
     Renames a file, even if that involves crossing file system boundaries.

This will remove to (if it exists), ensure that to's parent directory exists and move from, which involves deleting from as well.


Parameters:
  from - the file to move.
Parameters:
  to - the new file name.
throws:
  IOException - if anything bad happens during thisprocess.
public  FileresolveFile(File file, String filename)
     Interpret the filename as a file relative to the given file unless the filename already represents an absolute filename. Differs from new File(file, filename) in that the resulting File's path will always be a normalized, absolute pathname.
public  voidsetFileLastModified(File file, long time)
     Calls File.setLastModified(long time).
public  StringtoURI(String path)
     Constructs a file: URI that represents the external form of the given pathname.

Will be an absolute URI if the given path is absolute.

This code encodes non ASCII characters too.

The coding of the output is the same as what File.toURI().toASCIIString() produces

See dt-sysid which makes some mention of how characters not supported by URI Reference syntax should be escaped.
Parameters:
  path - the path in the local file system.
public  StringtoVMSPath(File f)
     Returns a VMS String representation of a File object. This is useful since the JVM by default internally converts VMS paths to Unix style. The returned String is always an absolute path.
Parameters:
  f - The File to get the VMS path for.
public static  StringtranslatePath(String toProcess)
     Translate a path into its native (platform specific) format.

This method uses PathTokenizer to separate the input path into its components.


Field Detail
BUF_SIZE
final static int BUF_SIZE(Code)



FAT_FILE_TIMESTAMP_GRANULARITY
final public static long FAT_FILE_TIMESTAMP_GRANULARITY(Code)
The granularity of timestamps under FAT.



NTFS_FILE_TIMESTAMP_GRANULARITY
final public static long NTFS_FILE_TIMESTAMP_GRANULARITY(Code)
The granularity of timestamps under the NT File System. NTFS has a granularity of 100 nanoseconds, which is less than 1 millisecond, so we round this up to 1 millisecond.



UNIX_FILE_TIMESTAMP_GRANULARITY
final public static long UNIX_FILE_TIMESTAMP_GRANULARITY(Code)
The granularity of timestamps under Unix.




Constructor Detail
FileUtils
protected FileUtils()(Code)
Empty constructor.




Method Detail
close
public static void close(Writer device)(Code)
Close a Writer without throwing any exception if something went wrong. Do not attempt to close it if the argument is null.
Parameters:
  device - output writer, can be null.



close
public static void close(Reader device)(Code)
Close a stream without throwing any exception if something went wrong. Do not attempt to close it if the argument is null.
Parameters:
  device - Reader, can be null.



close
public static void close(OutputStream device)(Code)
Close a stream without throwing any exception if something went wrong. Do not attempt to close it if the argument is null.
Parameters:
  device - stream, can be null.



close
public static void close(InputStream device)(Code)
Close a stream without throwing any exception if something went wrong. Do not attempt to close it if the argument is null.
Parameters:
  device - stream, can be null.



contentEquals
public boolean contentEquals(File f1, File f2) throws IOException(Code)
Compares the contents of two files.
Parameters:
  f1 - the file whose content is to be compared.
Parameters:
  f2 - the other file whose content is to be compared. true if the content of the files is the same.
throws:
  IOException - if the files cannot be read.



contentEquals
public boolean contentEquals(File f1, File f2, boolean textfile) throws IOException(Code)
Compares the contents of two files.
Parameters:
  f1 - the file whose content is to be compared.
Parameters:
  f2 - the other file whose content is to be compared.
Parameters:
  textfile - true if the file is to be treated as a text file anddifferences in kind of line break are to be ignored. true if the content of the files is the same.
throws:
  IOException - if the files cannot be read.
since:
   Ant 1.6.3



copyFile
public void copyFile(String sourceFile, String destFile) throws IOException(Code)
Convenience method to copy a file from a source to a destination. No filtering is performed.
Parameters:
  sourceFile - Name of file to copy from.Must not be null.
Parameters:
  destFile - Name of file to copy to.Must not be null.
throws:
  IOException - if the copying fails.



copyFile
public void copyFile(String sourceFile, String destFile, FilterSetCollection filters) throws IOException(Code)
Convenience method to copy a file from a source to a destination specifying if token filtering must be used.
Parameters:
  sourceFile - Name of file to copy from.Must not be null.
Parameters:
  destFile - Name of file to copy to.Must not be null.
Parameters:
  filters - the collection of filters to apply to this copy.
throws:
  IOException - if the copying fails.



copyFile
public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite) throws IOException(Code)
Convenience 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.
Parameters:
  sourceFile - Name of file to copy from.Must not be null.
Parameters:
  destFile - Name of file to copy to.Must not be null.
Parameters:
  filters - the collection of filters to apply to this copy.
Parameters:
  overwrite - Whether or not the destination file should beoverwritten if it already exists.
throws:
  IOException - if the copying fails.



copyFile
public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified) throws IOException(Code)
Convenience 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.
Parameters:
  sourceFile - Name of file to copy from.Must not be null.
Parameters:
  destFile - Name of file to copy to.Must not be null.
Parameters:
  filters - the collection of filters to apply to this copy.
Parameters:
  overwrite - Whether or not the destination file should beoverwritten if it already exists.
Parameters:
  preserveLastModified - Whether or not the last modified time ofthe resulting file should be set to thatof the source file.
throws:
  IOException - if the copying fails.



copyFile
public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified, String encoding) throws IOException(Code)
Convenience 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.
Parameters:
  sourceFile - Name of file to copy from.Must not be null.
Parameters:
  destFile - Name of file to copy to.Must not be null.
Parameters:
  filters - the collection of filters to apply to this copy.
Parameters:
  overwrite - Whether or not the destination file should beoverwritten if it already exists.
Parameters:
  preserveLastModified - Whether or not the last modified time ofthe resulting file should be set to thatof the source file.
Parameters:
  encoding - the encoding used to read and write the files.
throws:
  IOException - if the copying fails.
since:
   Ant 1.5



copyFile
public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, Vector filterChains, boolean overwrite, boolean preserveLastModified, String encoding, Project project) throws IOException(Code)
Convenience method to copy a file from a source to a destination specifying if token filtering must be used, if filter chains 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.
Parameters:
  sourceFile - Name of file to copy from.Must not be null.
Parameters:
  destFile - Name of file to copy to.Must not be null.
Parameters:
  filters - the collection of filters to apply to this copy.
Parameters:
  filterChains - filterChains to apply during the copy.
Parameters:
  overwrite - Whether or not the destination file should beoverwritten if it already exists.
Parameters:
  preserveLastModified - Whether or not the last modified time ofthe resulting file should be set to thatof the source file.
Parameters:
  encoding - the encoding used to read and write the files.
Parameters:
  project - the project instance.
throws:
  IOException - if the copying fails.
since:
   Ant 1.5



copyFile
public void copyFile(String sourceFile, String destFile, FilterSetCollection filters, Vector filterChains, boolean overwrite, boolean preserveLastModified, String inputEncoding, String outputEncoding, Project project) throws IOException(Code)
Convenience method to copy a file from a source to a destination specifying if token filtering must be used, if filter chains 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.
Parameters:
  sourceFile - Name of file to copy from.Must not be null.
Parameters:
  destFile - Name of file to copy to.Must not be null.
Parameters:
  filters - the collection of filters to apply to this copy.
Parameters:
  filterChains - filterChains to apply during the copy.
Parameters:
  overwrite - Whether or not the destination file should beoverwritten if it already exists.
Parameters:
  preserveLastModified - Whether or not the last modified time ofthe resulting file should be set to thatof the source file.
Parameters:
  inputEncoding - the encoding used to read the files.
Parameters:
  outputEncoding - the encoding used to write the files.
Parameters:
  project - the project instance.
throws:
  IOException - if the copying fails.
since:
   Ant 1.6



copyFile
public void copyFile(File sourceFile, File destFile) throws IOException(Code)
Convenience method to copy a file from a source to a destination. No filtering is performed.
Parameters:
  sourceFile - the file to copy from.Must not be null.
Parameters:
  destFile - the file to copy to.Must not be null.
throws:
  IOException - if the copying fails.



copyFile
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters) throws IOException(Code)
Convenience method to copy a file from a source to a destination specifying if token filtering must be used.
Parameters:
  sourceFile - the file to copy from.Must not be null.
Parameters:
  destFile - the file to copy to.Must not be null.
Parameters:
  filters - the collection of filters to apply to this copy.
throws:
  IOException - if the copying fails.



copyFile
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite) throws IOException(Code)
Convenience 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.
Parameters:
  sourceFile - the file to copy from.Must not be null.
Parameters:
  destFile - the file to copy to.Must not be null.
Parameters:
  filters - the collection of filters to apply to this copy.
Parameters:
  overwrite - Whether or not the destination file should beoverwritten if it already exists.
throws:
  IOException - if the copying fails.



copyFile
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified) throws IOException(Code)
Convenience 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.
Parameters:
  sourceFile - the file to copy from.Must not be null.
Parameters:
  destFile - the file to copy to.Must not be null.
Parameters:
  filters - the collection of filters to apply to this copy.
Parameters:
  overwrite - Whether or not the destination file should beoverwritten if it already exists.
Parameters:
  preserveLastModified - Whether or not the last modified time ofthe resulting file should be set to thatof the source file.
throws:
  IOException - if the copying fails.



copyFile
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, boolean overwrite, boolean preserveLastModified, String encoding) throws IOException(Code)
Convenience 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, the last modified time of destFile file should be made equal to the last modified time of sourceFile and which character encoding to assume.
Parameters:
  sourceFile - the file to copy from.Must not be null.
Parameters:
  destFile - the file to copy to.Must not be null.
Parameters:
  filters - the collection of filters to apply to this copy.
Parameters:
  overwrite - Whether or not the destination file should beoverwritten if it already exists.
Parameters:
  preserveLastModified - Whether or not the last modified time ofthe resulting file should be set to thatof the source file.
Parameters:
  encoding - the encoding used to read and write the files.
throws:
  IOException - if the copying fails.
since:
   Ant 1.5



copyFile
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, Vector filterChains, boolean overwrite, boolean preserveLastModified, String encoding, Project project) throws IOException(Code)
Convenience method to copy a file from a source to a destination specifying if token filtering must be used, if filter chains 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.
Parameters:
  sourceFile - the file to copy from.Must not be null.
Parameters:
  destFile - the file to copy to.Must not be null.
Parameters:
  filters - the collection of filters to apply to this copy.
Parameters:
  filterChains - filterChains to apply during the copy.
Parameters:
  overwrite - Whether or not the destination file should beoverwritten if it already exists.
Parameters:
  preserveLastModified - Whether or not the last modified time ofthe resulting file should be set to thatof the source file.
Parameters:
  encoding - the encoding used to read and write the files.
Parameters:
  project - the project instance.
throws:
  IOException - if the copying fails.
since:
   Ant 1.5



copyFile
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters, Vector filterChains, boolean overwrite, boolean preserveLastModified, String inputEncoding, String outputEncoding, Project project) throws IOException(Code)
Convenience method to copy a file from a source to a destination specifying if token filtering must be used, if filter chains 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.
Parameters:
  sourceFile - the file to copy from.Must not be null.
Parameters:
  destFile - the file to copy to.Must not be null.
Parameters:
  filters - the collection of filters to apply to this copy.
Parameters:
  filterChains - filterChains to apply during the copy.
Parameters:
  overwrite - Whether or not the destination file should beoverwritten if it already exists.
Parameters:
  preserveLastModified - Whether or not the last modified time ofthe resulting file should be set to thatof the source file.
Parameters:
  inputEncoding - the encoding used to read the files.
Parameters:
  outputEncoding - the encoding used to write the files.
Parameters:
  project - the project instance.
throws:
  IOException - if the copying fails.
since:
   Ant 1.6



createNewFile
public boolean createNewFile(File f) throws IOException(Code)
This was originally an emulation of File.createNewFile for JDK 1.1, but it is now implemented using that method (Ant 1.6.3 onwards).

This method has historically not guaranteed that the operation was atomic. In its current implementation it is.
Parameters:
  f - the file to be created. true if the file did not exist already.
throws:
  IOException - on error.
since:
   Ant 1.5




createNewFile
public boolean createNewFile(File f, boolean mkdirs) throws IOException(Code)
Create a new file, optionally creating parent directories.
Parameters:
  f - the file to be created.
Parameters:
  mkdirs - boolean whether to create parent directories. true if the file did not exist already.
throws:
  IOException - on error.
since:
   Ant 1.6.3



createTempFile
public File createTempFile(String prefix, String suffix, File parentDir)(Code)
Create a temporary file in a given directory.

The file denoted by the returned abstract pathname did not exist before this method was invoked, any subsequent invocation of this method will yield a different file name.

The filename is prefixNNNNNsuffix where NNNN is a random number.

This method is different from File.createTempFile() of JDK 1.2 as it doesn't create the file itself. It uses the location pointed to by java.io.tmpdir when the parentDir attribute is null.


Parameters:
  prefix - prefix before the random number.
Parameters:
  suffix - file extension; include the '.'.
Parameters:
  parentDir - Directory to create the temporary file in;java.io.tmpdir used if not specified. a File reference to the new temporary file.
since:
   Ant 1.5



createTempFile
public File createTempFile(String prefix, String suffix, File parentDir, boolean deleteOnExit)(Code)
Create a temporary file in a given directory.

The file denoted by the returned abstract pathname did not exist before this method was invoked, any subsequent invocation of this method will yield a different file name.

The filename is prefixNNNNNsuffix where NNNN is a random number.

This method is different from File.createTempFile() of JDK 1.2 as it doesn't create the file itself. It uses the location pointed to by java.io.tmpdir when the parentDir attribute is null.


Parameters:
  prefix - prefix before the random number.
Parameters:
  suffix - file extension; include the '.'.
Parameters:
  parentDir - Directory to create the temporary file in;
Parameters:
  deleteOnExit - whether to set the tempfile for deletion onnormal VM exit.java.io.tmpdir used if not specified. a File reference to the new temporary file.
since:
   Ant 1.7



delete
public static void delete(File file)(Code)
Delete the file with File.delete if the argument is not null. Do nothing on a null argument.
Parameters:
  file - file to delete.



dissect
public String[] dissect(String path)(Code)
Dissect the specified absolute path.
Parameters:
  path - the path to dissect. String[] {root, remaining path}.
throws:
  java.lang.NullPointerException - if path is null.
since:
   Ant 1.7



fileNameEquals
public boolean fileNameEquals(File f1, File f2)(Code)
Compares two filenames.

Unlike java.io.File#equals this method will try to compare the absolute paths and "normalize" the filenames before comparing them.


Parameters:
  f1 - the file whose name is to be compared.
Parameters:
  f2 - the other file whose name is to be compared. true if the file are for the same file.
since:
   Ant 1.5.3



fromURI
public String fromURI(String uri)(Code)
Constructs a file path from a file: URI.

Will be an absolute path if the given URI is absolute.

Swallows '%' that are not followed by two characters, doesn't deal with non-ASCII characters.


Parameters:
  uri - the URI designating a file in the local filesystem. the local file system path for the file.
since:
   Ant 1.6



getDefaultEncoding
public String getDefaultEncoding()(Code)
Get the default encoding. This is done by opening an InputStreamReader on a dummy InputStream and getting the encoding. Could use System.getProperty("file.encoding"), but cannot see where this is documented. the default file encoding.



getFileTimestampGranularity
public long getFileTimestampGranularity()(Code)
Get the granularity of file timestamps. The choice is made based on OS, which is incorrect--it should really be by filesystem. We do not have an easy way to probe for file systems, however, so this heuristic gives us a decent default. the difference, in milliseconds, which two file timestamps must havein order for the two files to be considered to have different timestamps.



getFileURL
public URL getFileURL(File file) throws MalformedURLException(Code)
Get the URL for a file taking into account # characters.
Parameters:
  file - the file whose URL representation is required. The FileURL value.
throws:
  MalformedURLException - if the URL representation cannot beformed.



getFileUtils
public static FileUtils getFileUtils()(Code)
Method to retrieve The FileUtils, which is shared by all users of this method. an instance of FileUtils.
since:
   Ant 1.6.3



getParentFile
public File getParentFile(File f)(Code)
This was originally an emulation of File.getParentFile for JDK 1.1, but it is now implemented using that method (Ant 1.6.3 onwards).
Parameters:
  f - the file whose parent is required. the given file's parent, or null if the file does not have aparent.
since:
   1.10File.getParentFile



getPath
public static String getPath(List pathStack)(Code)
Gets path from a List of Strings.
Parameters:
  pathStack - List of Strings to be concatedas a path. String, never null
since:
   Ant 1.7



getPath
public static String getPath(List pathStack, char separatorChar)(Code)
Gets path from a List of Strings.
Parameters:
  pathStack - List of Strings to be concatedas a path.
Parameters:
  separatorChar - char to be used as separator between names inpath String, never null
since:
   Ant 1.7



getPathStack
public static String[] getPathStack(String path)(Code)
Gets all names of the path as an array of Strings.
Parameters:
  path - to get names from Strings, never null
since:
   Ant 1.7



getRelativePath
public static String getRelativePath(File fromFile, File toFile) throws Exception(Code)
Calculates the relative path between two files.

Implementation note:
This function my throw an IOException if an I/O error occurs because its use of the canonical pathname may require filesystem queries.


Parameters:
  fromFile - the File to calculate the path from
Parameters:
  toFile - the File to calculate the path to the relative path between the files
throws:
  Exception - for undocumented reasons
See Also:   File.getCanonicalPath
since:
   Ant 1.7



isAbsolutePath
public static boolean isAbsolutePath(String filename)(Code)
Verifies that the specified filename represents an absolute path. Differs from new java.io.File("filename").isAbsolute() in that a path beginning with a double file separator--signifying a Windows UNC--must at minimum match "\\a\b" to be considered an absolute path.
Parameters:
  filename - the filename to be checked. true if the filename represents an absolute path.
throws:
  java.lang.NullPointerException - if filename is null.
since:
   Ant 1.6.3



isContextRelativePath
public static boolean isContextRelativePath(String filename)(Code)
On DOS and NetWare, the evaluation of certain file specifications is context-dependent. These are filenames beginning with a single separator (relative to current root directory) and filenames with a drive specification and no intervening separator (relative to current directory of the specified root).
Parameters:
  filename - the filename to evaluate. true if the filename is relative to system context.
throws:
  java.lang.NullPointerException - if filename is null.
since:
   Ant 1.7



isLeadingPath
public boolean isLeadingPath(File leading, File path)(Code)
Learn whether one path "leads" another.
Parameters:
  leading - The leading path, must not be null, must be absolute.
Parameters:
  path - The path to remove from, must not be null, must be absolute. true if path starts with leading; false otherwise.
since:
   Ant 1.7



isSymbolicLink
public boolean isSymbolicLink(File parent, String name) throws IOException(Code)
Checks whether a given file is a symbolic link.

It doesn't really test for symbolic links but whether the canonical and absolute paths of the file are identical--this may lead to false positives on some platforms.


Parameters:
  parent - the parent directory of the file to test
Parameters:
  name - the name of the file to test. true if the file is a symbolic link.
throws:
  IOException - on error.
since:
   Ant 1.5



isUpToDate
public boolean isUpToDate(File source, File dest, long granularity)(Code)
Returns true if the source is older than the dest. If the dest file does not exist, then the test returns false; it is implicitly not up do date.
Parameters:
  source - source file (should be the older).
Parameters:
  dest - dest file (should be the newer).
Parameters:
  granularity - an offset added to the source time. true if the source is older than the dest after accountingfor granularity.
since:
   Ant 1.6.3



isUpToDate
public boolean isUpToDate(File source, File dest)(Code)
Returns true if the source is older than the dest.
Parameters:
  source - source file (should be the older).
Parameters:
  dest - dest file (should be the newer). true if the source is older than the dest, taking the granularity into account.
since:
   Ant 1.6.3



isUpToDate
public boolean isUpToDate(long sourceTime, long destTime, long granularity)(Code)
Compare two timestamps for being up to date using the specified granularity.
Parameters:
  sourceTime - timestamp of source file.
Parameters:
  destTime - timestamp of dest file.
Parameters:
  granularity - os/filesys granularity. true if the dest file is considered up to date.



isUpToDate
public boolean isUpToDate(long sourceTime, long destTime)(Code)
Compare two timestamps for being up to date using the current granularity.
Parameters:
  sourceTime - timestamp of source file.
Parameters:
  destTime - timestamp of dest file. true if the dest file is considered up to date.



newFileUtils
public static FileUtils newFileUtils()(Code)
Factory method. a new instance of FileUtils.



normalize
public File normalize(String path)(Code)
"Normalize" the given absolute path.

This includes:

  • Uppercase the drive letter if there is one.
  • Remove redundant slashes after the drive spec.
  • Resolve all ./, .\, ../ and ..\ sequences.
  • DOS style paths that start with a drive letter will have \ as the separator.
Unlike File.getCanonicalPath this method specifically does not resolve symbolic links.
Parameters:
  path - the path to be normalized. the normalized version of the path.
throws:
  java.lang.NullPointerException - if path is null.



readFully
final public static String readFully(Reader rdr) throws IOException(Code)
Read from reader till EOF.
Parameters:
  rdr - the reader from which to read. the contents read out of the given reader.
throws:
  IOException - if the contents could not be read out from thereader.



readFully
final public static String readFully(Reader rdr, int bufferSize) throws IOException(Code)
Read from reader till EOF.
Parameters:
  rdr - the reader from which to read.
Parameters:
  bufferSize - the buffer size to use when reading. the contents read out of the given reader.
throws:
  IOException - if the contents could not be read out from thereader.



removeLeadingPath
public String removeLeadingPath(File leading, File path)(Code)
Removes a leading path from a second path.
Parameters:
  leading - The leading path, must not be null, must be absolute.
Parameters:
  path - The path to remove from, must not be null, must be absolute. path's normalized absolute if it doesn't start withleading; path's path with leading's path removed otherwise.
since:
   Ant 1.5



rename
public void rename(File from, File to) throws IOException(Code)
Renames a file, even if that involves crossing file system boundaries.

This will remove to (if it exists), ensure that to's parent directory exists and move from, which involves deleting from as well.


Parameters:
  from - the file to move.
Parameters:
  to - the new file name.
throws:
  IOException - if anything bad happens during thisprocess. Note that to may have been deletedalready when this happens.
since:
   Ant 1.6



resolveFile
public File resolveFile(File file, String filename)(Code)
Interpret the filename as a file relative to the given file unless the filename already represents an absolute filename. Differs from new File(file, filename) in that the resulting File's path will always be a normalized, absolute pathname. Also, if it is determined that filename is context-relative, file will be discarded and the reference will be resolved using available context/state information about the filesystem.
Parameters:
  file - the "reference" file for relative paths. Thisinstance must be an absolute file and must not contain"./" or "../" sequences (same for \ insteadof /). If it is null, this call is equivalent tonew java.io.File(filename).getAbsoluteFile().
Parameters:
  filename - a file name. an absolute file.
throws:
  java.lang.NullPointerException - if filename is null.



setFileLastModified
public void setFileLastModified(File file, long time)(Code)
Calls File.setLastModified(long time). Originally written to to dynamically bind to that call on Java1.2+.
Parameters:
  file - the file whose modified time is to be set
Parameters:
  time - the time to which the last modified time is to be set.if this is -1, the current time is used.



toURI
public String toURI(String path)(Code)
Constructs a file: URI that represents the external form of the given pathname.

Will be an absolute URI if the given path is absolute.

This code encodes non ASCII characters too.

The coding of the output is the same as what File.toURI().toASCIIString() produces

See dt-sysid which makes some mention of how characters not supported by URI Reference syntax should be escaped.
Parameters:
  path - the path in the local file system. the URI version of the local path.
since:
   Ant 1.6



toVMSPath
public String toVMSPath(File f)(Code)
Returns a VMS String representation of a File object. This is useful since the JVM by default internally converts VMS paths to Unix style. The returned String is always an absolute path.
Parameters:
  f - The File to get the VMS path for. The absolute VMS path to f.



translatePath
public static String translatePath(String toProcess)(Code)
Translate a path into its native (platform specific) format.

This method uses PathTokenizer to separate the input path into its components. This handles DOS style paths in a relatively sensible way. The file separators are then converted to their platform specific versions.
Parameters:
  toProcess - The path to be translated.May be null. the native version of the specified path oran empty string if the path is null or empty.
since:
   ant 1.7
See Also:   PathTokenizer




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.