@NotThreadSafe public class FileSystemResource extends Object implements IReadWriteResource
IReadableResource and
IWritableResource interfaces for file
system objects.| Constructor and Description |
|---|
FileSystemResource(File aFile) |
FileSystemResource(File aParentFile,
String sChildPath) |
FileSystemResource(Path aPath) |
FileSystemResource(String sFilename) |
FileSystemResource(String sParentPath,
String sChildPath) |
FileSystemResource(URI aURI) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canExecute()
Tests whether the application can execute the file denoted by this abstract
pathname.
|
boolean |
canRead()
Tests whether the application can read the file denoted by this abstract
pathname.
|
boolean |
canWrite()
Tests whether the application can modify the file denoted by this abstract
pathname.
|
boolean |
equals(Object o) |
boolean |
exists() |
File |
getAsFile() |
URL |
getAsURL() |
FileInputStream |
getInputStream()
Get the input stream to read from the object.
|
FileOutputStream |
getOutputStream(EAppend eAppend)
Get the output stream to read from the object.
|
String |
getPath() |
FileSystemResource |
getReadableCloneForPath(String sPath)
Get a new resource of the same implementation type as this object but for a
different path.
|
Reader |
getReader(Charset aCharset)
Get an
Reader based on this input stream provider using the given
charset. |
String |
getResourceID() |
FileSystemResource |
getWritableCloneForPath(String sPath)
Get a new resource of the same implementation type as this object but for a
different path.
|
Writer |
getWriter(Charset aCharset,
EAppend eAppend)
Get an
Writer based on this output stream provider using the given
charset. |
int |
hashCode() |
boolean |
isReadMultiple()
Check if the
InputStream from IHasInputStream.getInputStream() can be
acquired more than once. |
boolean |
isWriteMultiple()
Check if the
OutputStream from IHasOutputStream.getOutputStream(EAppend)
can be qcquired more than once or not. |
String |
toString() |
public FileSystemResource(@Nonnull String sParentPath, @Nonnull String sChildPath)
@Nonnull public String getResourceID()
getResourceID in interface IResourceBasenull resource ID used e.g. for system IDs in XML
resolving.@Nonnull public String getPath()
getPath in interface IResourceBasenull@Nullable public FileInputStream getInputStream()
IHasInputStreamInputStream needs to be created!getInputStream in interface IHasInputStreamnull if resolving failed.@Nullable public Reader getReader(@Nonnull Charset aCharset)
IHasInputStreamAndReaderReader based on this input stream provider using the given
charset.getReader in interface IHasInputStreamAndReaderaCharset - The charset to use. May not be null.null if no input stream could be retrieved.public final boolean isReadMultiple()
IHasInputStreamInputStream from IHasInputStream.getInputStream() can be
acquired more than once.isReadMultiple in interface IHasInputStreamtrue if the input stream can be acquired more than
once, false if not.@Nullable public FileOutputStream getOutputStream(@Nonnull EAppend eAppend)
IHasOutputStreamOutputStream needs to be created!getOutputStream in interface IHasOutputStreameAppend - appending mode. May not be null.null if resolving failed.@Nullable public Writer getWriter(@Nonnull Charset aCharset, @Nonnull EAppend eAppend)
IHasOutputStreamAndWriterWriter based on this output stream provider using the given
charset.getWriter in interface IHasOutputStreamAndWriteraCharset - The charset to use. May not be null.eAppend - Appending mode. May not be null.null if no output stream could be retrieved.public final boolean isWriteMultiple()
IHasOutputStreamOutputStream from IHasOutputStream.getOutputStream(EAppend)
can be qcquired more than once or not.isWriteMultiple in interface IHasOutputStreamtrue if the output stream can be acquired more than
once, false if not.public boolean exists()
exists in interface IResourceBasetrue if the resource exists, false
otherwise.@Nullable public URL getAsURL()
getAsURL in interface IResourceBasenull
if this resource cannot be represented as an URL.@Nonnull public File getAsFile()
getAsFile in interface IResourceBasenull
if this resource cannot be represented as a file.@Nonnull public FileSystemResource getReadableCloneForPath(@Nonnull String sPath)
IReadableResourcegetReadableCloneForPath in interface IReadableResourcesPath - The new path to use. May not be null.null.@Nonnull public FileSystemResource getWritableCloneForPath(@Nonnull String sPath)
IWritableResourcegetWritableCloneForPath in interface IWritableResourcesPath - The new path to use. May not be null.null.public boolean canRead()
true if and only if the file specified by this
abstract pathname exists and can be read by the
application; false otherwisepublic boolean canWrite()
true if 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; false
otherwise.public boolean canExecute()
true if and only if the abstract pathname exists
and the application is allowed to execute the fileCopyright © 2014–2017 Philip Helger. All rights reserved.