Package com.helger.commons.io.resource
Class FileSystemResource
java.lang.Object
com.helger.commons.io.resource.FileSystemResource
- All Implemented Interfaces:
IHasInputStream,IHasInputStreamAndReader,IHasOutputStream,IHasOutputStreamAndWriter,IReadableResource,IReadWriteResource,IResourceBase,IWritableResource
Implementation of the
IReadableResource and
IWritableResource interfaces for file
system objects.- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionFileSystemResource(File aFile) FileSystemResource(File aParentFile, String sChildPath) FileSystemResource(String sFilename) FileSystemResource(String sParentPath, String sChildPath) FileSystemResource(URI aURI) FileSystemResource(Path aPath) -
Method Summary
Modifier and TypeMethodDescriptionbooleanTests whether the application can execute the file denoted by this abstract pathname.booleancanRead()Tests whether the application can read the file denoted by this abstract pathname.booleancanWrite()Tests whether the application can modify the file denoted by this abstract pathname.booleanbooleanexists()getAsURL()Get the input stream to read from the object.getOutputStream(EAppend eAppend) Get the output stream to read from the object.getPath()getReadableCloneForPath(String sPath) Get a new resource of the same implementation type as this object but for a different path.Get aReaderbased on this input stream provider using the given charset.getWritableCloneForPath(String sPath) Get a new resource of the same implementation type as this object but for a different path.Get aWriterbased on this output stream provider using the given charset.inthashCode()final booleanCheck if theInputStreamfromIHasInputStream.getInputStream()andIHasInputStream.getBufferedInputStream()can be acquired more than once.final booleanCheck if theOutputStreamfromIHasOutputStream.getOutputStream(EAppend)orIHasOutputStream.getBufferedOutputStream(EAppend)can be acquired more than once or not.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.commons.io.IHasInputStream
getBufferedInputStream, withBufferedInputStreamDo, withInputStreamDoMethods inherited from interface com.helger.commons.io.IHasInputStreamAndReader
getBufferedReaderMethods inherited from interface com.helger.commons.io.IHasOutputStream
getBufferedOutputStreamMethods inherited from interface com.helger.commons.io.IHasOutputStreamAndWriter
getBufferedWriter
-
Constructor Details
-
FileSystemResource
-
FileSystemResource
-
FileSystemResource
-
FileSystemResource
-
FileSystemResource
-
FileSystemResource
-
-
Method Details
-
getResourceID
- Specified by:
getResourceIDin interfaceIResourceBase- Returns:
- A non-
nullresource ID used e.g. for system IDs in XML resolving.
-
getPath
- Specified by:
getPathin interfaceIResourceBase- Returns:
- The requested path. Never
null
-
getInputStream
Description copied from interface:IHasInputStreamGet the input stream to read from the object. Each time this method is called, a newInputStreamneeds to be created.- Specified by:
getInputStreamin interfaceIHasInputStream- Returns:
nullif resolving failed.
-
getReader
Description copied from interface:IHasInputStreamAndReaderGet aReaderbased on this input stream provider using the given charset.- Specified by:
getReaderin interfaceIHasInputStreamAndReader- Parameters:
aCharset- The charset to use. May not benull.- Returns:
nullif no input stream could be retrieved.
-
isReadMultiple
public final boolean isReadMultiple()Description copied from interface:IHasInputStreamCheck if theInputStreamfromIHasInputStream.getInputStream()andIHasInputStream.getBufferedInputStream()can be acquired more than once.- Specified by:
isReadMultiplein interfaceIHasInputStream- Returns:
trueif the input stream can be acquired more than once,falseif not.
-
getOutputStream
Description copied from interface:IHasOutputStreamGet the output stream to read from the object. Each time this method is call, a newOutputStreamneeds to be created!- Specified by:
getOutputStreamin interfaceIHasOutputStream- Parameters:
eAppend- appending mode. May not benull.- Returns:
nullif resolving failed.
-
getWriter
Description copied from interface:IHasOutputStreamAndWriterGet aWriterbased on this output stream provider using the given charset.- Specified by:
getWriterin interfaceIHasOutputStreamAndWriter- Parameters:
aCharset- The charset to use. May not benull.eAppend- Appending mode. May not benull.- Returns:
nullif no output stream could be retrieved.
-
isWriteMultiple
public final boolean isWriteMultiple()Description copied from interface:IHasOutputStreamCheck if theOutputStreamfromIHasOutputStream.getOutputStream(EAppend)orIHasOutputStream.getBufferedOutputStream(EAppend)can be acquired more than once or not.- Specified by:
isWriteMultiplein interfaceIHasOutputStream- Returns:
trueif the output stream can be acquired more than once,falseif not.
-
exists
public boolean exists()- Specified by:
existsin interfaceIResourceBase- Returns:
trueif the resource exists,falseotherwise.
-
getAsURL
- Specified by:
getAsURLin interfaceIResourceBase- Returns:
- the URL representation of this resource. May be
nullif this resource cannot be represented as an URL.
-
getAsFile
- Specified by:
getAsFilein interfaceIResourceBase- Returns:
- the File representation of this resource. May be
nullif this resource cannot be represented as a file.
-
getReadableCloneForPath
Description copied from interface:IReadableResourceGet a new resource of the same implementation type as this object but for a different path.- Specified by:
getReadableCloneForPathin interfaceIReadableResource- Parameters:
sPath- The new path to use. May not benull.- Returns:
- The resource of the same implementation but a different path. May
not be
null.
-
getWritableCloneForPath
Description copied from interface:IWritableResourceGet a new resource of the same implementation type as this object but for a different path.- Specified by:
getWritableCloneForPathin interfaceIWritableResource- Parameters:
sPath- The new path to use. May not benull.- Returns:
- The resource of the same implementation but a different path. May
not be
null.
-
canRead
public boolean canRead()Tests whether the application can read the file denoted by this abstract pathname.- Returns:
trueif and only if the file specified by this abstract pathname exists and can be read by the application;falseotherwise
-
canWrite
public boolean canWrite()Tests whether the application can modify the file denoted by this abstract pathname.- Returns:
trueif and only if the file system actually contains a file denoted by this abstract pathname and the application is allowed to write to the file;falseotherwise.
-
canExecute
public boolean canExecute()Tests whether the application can execute the file denoted by this abstract pathname.- Returns:
trueif and only if the abstract pathname exists and the application is allowed to execute the file
-
equals
-
hashCode
public int hashCode() -
toString
-