Class FileResource
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.types.DataType
org.apache.tools.ant.types.Resource
org.apache.tools.ant.types.resources.FileResource
- All Implemented Interfaces:
- Cloneable,- Comparable<Resource>,- Iterable<Resource>,- ResourceCollection,- ResourceFactory,- Appendable,- FileProvider,- Touchable
public class FileResource
extends Resource
implements Touchable, FileProvider, ResourceFactory, Appendable
A Resource representation of a File.
- Since:
- Ant 1.7
- 
Field SummaryFields inherited from class org.apache.tools.ant.types.ResourceMAGIC, UNKNOWN_DATETIME, UNKNOWN_SIZEFields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
- 
Constructor SummaryConstructorsConstructorDescriptionDefault constructor.FileResource(File f) Construct a new FileResource from a File.FileResource(File b, String name) Construct a new FileResource using the specified basedir and relative name.FileResource(Project p, File f) Create a new FileResource.FileResource(Project p, String s) Constructor for Ant attribute introspection.
- 
Method SummaryModifier and TypeMethodDescriptionintCompare this FileResource to another Resource.booleanCompare another Object to this FileResource for equality.Get an appending OutputStream.Return the basedir to which the name is relative.getFile()Get the file represented by this FileResource.Return an InputStream for reading the contents of this Resource.longGet the modification time in milliseconds since 01.01.1970 .getName()Get the name of this FileResource.protected FileGet the file represented by this FileResource, ensuring it is not null.Get an OutputStream for the Resource.protected FileResourcegetRef()Perform the check for circular references and return the referenced Resource.getResource(String path) Create a new resource that matches a relative or absolute path.longgetSize()Get the size of this Resource.inthashCode()Get the hash code for this Resource.booleanLearn whether the resource is a directory.booleanisExists()Learn whether this file exists.booleanFulfill the ResourceCollection contract.voidsetBaseDir(File b) Set the basedir for this FileResource.voidSet the File for this FileResource.voidOverrides the super version.toString()Get the string representation of this Resource.voidtouch(long modTime) Implement the Touchable interface.Methods inherited from class org.apache.tools.ant.types.Resourceas, asOptional, clone, getMagicNumber, iterator, setDirectory, setExists, setLastModified, setName, setSize, size, toLongStringMethods inherited from class org.apache.tools.ant.types.DataTypecheckAttributesAllowed, checkChildrenAllowed, circularReference, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, tooManyAttributesMethods inherited from class org.apache.tools.ant.ProjectComponentgetDescription, getLocation, getProject, log, log, setDescription, setLocation, setProjectMethods inherited from class java.lang.Objectfinalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliteratorMethods inherited from interface org.apache.tools.ant.types.ResourceCollectionisEmpty, stream
- 
Constructor Details- 
FileResourcepublic FileResource()Default constructor.
- 
FileResource
- 
FileResourceConstruct a new FileResource from a File.- Parameters:
- f- the File represented.
 
- 
FileResource
- 
FileResource
 
- 
- 
Method Details- 
setFileSet the File for this FileResource.- Parameters:
- f- the File to be represented.
 
- 
getFileGet the file represented by this FileResource.- Specified by:
- getFilein interface- FileProvider
- Returns:
- the File.
 
- 
setBaseDirSet the basedir for this FileResource.- Parameters:
- b- the basedir as File.
 
- 
getBaseDirReturn the basedir to which the name is relative.- Returns:
- the basedir as File.
 
- 
setRefid
- 
getName
- 
isExists
- 
getLastModifiedpublic long getLastModified()Get the modification time in milliseconds since 01.01.1970 .- Overrides:
- getLastModifiedin class- Resource
- Returns:
- 0 if the resource does not exist.
 
- 
isDirectorypublic boolean isDirectory()Learn whether the resource is a directory.- Overrides:
- isDirectoryin class- Resource
- Returns:
- boolean flag indicating if the resource is a directory.
 
- 
getSize
- 
getInputStreamReturn an InputStream for reading the contents of this Resource.- Overrides:
- getInputStreamin class- Resource
- Returns:
- an InputStream object.
- Throws:
- IOException- if an error occurs.
 
- 
getOutputStreamGet an OutputStream for the Resource.- Overrides:
- getOutputStreamin class- Resource
- Returns:
- an OutputStream to which content can be written.
- Throws:
- IOException- if unable to provide the content of this Resource as a stream.
- UnsupportedOperationException- if OutputStreams are not supported for this Resource type.
 
- 
getAppendOutputStreamGet an appending OutputStream.- Specified by:
- getAppendOutputStreamin interface- Appendable
- Returns:
- OutputStream
- Throws:
- IOException- if anything goes wrong
 
- 
compareToCompare this FileResource to another Resource.- Specified by:
- compareToin interface- Comparable<Resource>
- Overrides:
- compareToin class- Resource
- Parameters:
- another- the other Resource against which to compare.
- Returns:
- a negative integer, zero, or a positive integer as this FileResource is less than, equal to, or greater than the specified Resource.
 
- 
equals
- 
hashCode
- 
toString
- 
isFilesystemOnlypublic boolean isFilesystemOnly()Fulfill the ResourceCollection contract.- Specified by:
- isFilesystemOnlyin interface- ResourceCollection
- Overrides:
- isFilesystemOnlyin class- Resource
- Returns:
- whether this Resource is a FileResource.
 
- 
touch
- 
getNotNullFileGet the file represented by this FileResource, ensuring it is not null.- Returns:
- the not-null File.
- Throws:
- BuildException- if file is null.
 
- 
getResourceCreate a new resource that matches a relative or absolute path. If the current instance has a compatible baseDir attribute, it is copied.- Specified by:
- getResourcein interface- ResourceFactory
- Parameters:
- path- relative/absolute path to a resource
- Returns:
- a new resource of type FileResource
- Throws:
- BuildException- if desired
- Since:
- Ant1.8
 
- 
getRefDescription copied from class:ResourcePerform the check for circular references and return the referenced Resource.
 
-