|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.File
railo.commons.io.res.type.file.FileResource
public final class FileResource
Implementation og Resource for the local filesystem (java.io.File)
Field Summary |
---|
Fields inherited from class java.io.File |
---|
pathSeparator, pathSeparatorChar, separator, separatorChar |
Fields inherited from interface railo.commons.io.res.Resource |
---|
ATTRIBUTE_ARCHIVE, ATTRIBUTE_HIDDEN, ATTRIBUTE_SYSTEM |
Method Summary | |
---|---|
boolean |
canRead()
Tests whether the application can read the resource denoted by this abstract pathname. |
boolean |
canWrite()
Tests whether the application can modify the resource denoted by this abstract pathname. |
void |
copyFrom(Resource res,
boolean append)
copy data of given resource to current |
void |
copyTo(Resource res,
boolean append)
copy current resource data to given resource |
void |
createDirectory(boolean createParentWhenNotExists)
Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories if flag "createParentWhenNotExists" is set to true. |
void |
createFile(boolean createParentWhenNotExists)
Creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. |
boolean |
createNewFile()
Creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. |
boolean |
delete()
Deletes the resource denoted by this abstract pathname. |
boolean |
equals(Object other)
|
boolean |
exists()
Tests whether the resource denoted by this abstract pathname exists. |
Resource |
getAbsoluteResource()
Returns the absolute form of this abstract pathname. |
boolean |
getAttribute(short attribute)
return value of a specific attribute |
Resource |
getCanonicalResource()
Returns the canonical form of this abstract pathname. |
ContentType |
getContentType()
|
InputStream |
getInputStream()
|
int |
getMode()
|
OutputStream |
getOutputStream()
|
OutputStream |
getOutputStream(boolean append)
|
Resource |
getParentResource()
Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent
directory. |
String |
getReal(String realpath)
returns a resource path that is relative to the current resource |
Resource |
getRealResource(String realpath)
returns a resource that is relative to the current resource |
ResourceProvider |
getResourceProvider()
|
boolean |
isAbsolute()
Tests whether this abstract pathname is absolute. |
boolean |
isArchive()
Tests whether the resource named by this abstract pathname is a archive resource. |
boolean |
isDirectory()
Tests whether the resource denoted by this abstract pathname is a directory. |
boolean |
isFile()
Tests whether the file denoted by this abstract pathname is a normal file. |
boolean |
isHidden()
Tests whether the resource named by this abstract pathname is a hidden resource. |
boolean |
isReadable()
Tests whether the application can read the resource denoted by this abstract pathname. |
boolean |
isSystem()
Tests whether the resource named by this abstract pathname is a system resource. |
boolean |
isWriteable()
Tests whether the application can modify the resource denoted by this abstract pathname. |
long |
lastModified()
Returns the time that the resource denoted by this abstract pathname was last modified. |
long |
length()
Returns the length of the resource denoted by this abstract pathname. |
String[] |
list()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname. |
String[] |
list(ResourceFilter filter)
|
String[] |
list(ResourceNameFilter filter)
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. |
Resource[] |
listResources()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname. |
Resource[] |
listResources(ResourceFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. |
Resource[] |
listResources(ResourceNameFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. |
boolean |
mkdir()
Creates the directory named by this abstract pathname. |
boolean |
mkdirs()
Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. |
void |
moveTo(Resource dest)
Move/renames the file denoted by this abstract pathname. |
void |
remove(boolean alsoRemoveChildren)
Deletes the resource denoted by this abstract pathname. |
boolean |
renameTo(Resource dest)
Move/renames the file denoted by this abstract pathname. |
void |
setArchive(boolean value)
sets archive attribute of the resource |
void |
setAttribute(short attribute,
boolean value)
sets a attribute on the resource if supported otherwise it will ign |
void |
setHidden(boolean value)
sets hidden attribute of the resource |
boolean |
setLastModified(long time)
Sets the last-modified time of the file or directory named by this abstract pathname. |
void |
setMode(int mode)
|
boolean |
setReadable(boolean value)
|
boolean |
setReadOnly()
Marks the file or directory named by this abstract pathname so that only read operations are allowed. |
void |
setSystem(boolean value)
sets system attribute of the resource |
boolean |
setWritable(boolean value)
|
Methods inherited from class java.io.File |
---|
canExecute, compareTo, createTempFile, createTempFile, deleteOnExit, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, list, listFiles, listFiles, listFiles, listRoots, renameTo, setExecutable, setExecutable, setReadable, setWritable, toString, toURI, toURL |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface railo.commons.io.res.Resource |
---|
getAbsolutePath, getCanonicalPath, getName, getParent, getPath |
Method Detail |
---|
public void copyFrom(Resource res, boolean append) throws IOException
Resource
copyFrom
in interface Resource
IOException
Resource.copyFrom(railo.commons.io.res.Resource,boolean)
public void copyTo(Resource res, boolean append) throws IOException
Resource
copyTo
in interface Resource
IOException
Resource.copyTo(railo.commons.io.res.Resource,boolean)
public Resource getAbsoluteResource()
Resource
getAbsoluteResource
in interface Resource
Resource.getAbsoluteResource()
public Resource getCanonicalResource() throws IOException
Resource
getCanonicalResource
in interface Resource
IOException
- If an I/O error occurs, which is possible because the
construction of the canonical pathname may require
filesystem queriesResource.getCanonicalResource()
public Resource getParentResource()
Resource
null
if this pathname does not name a parent
directory.
The parent of an abstract pathname consists of the pathname's prefix, if any, and each name in the pathname's name sequence except for the last. If the name sequence is empty then the pathname does not name a parent directory.
getParentResource
in interface Resource
null
if this pathname
does not name a parentResource.getParentResource()
public Resource[] listResources()
Resource
If this abstract pathname does not denote a directory, then this
method returns null
. Otherwise an array of
File
objects is returned, one for each file or directory in
the directory. Therefore if this pathname
is absolute then each resulting pathname is absolute; if this pathname
is relative then each resulting pathname will be relative to the same
directory.
There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
listResources
in interface Resource
null
if this abstract pathname
does not denote a directory, or if an I/O error occurs.Resource.listResources()
public String[] list(ResourceFilter filter)
list
in interface Resource
res.Resource#list(res.filter.ResourceFilter)
public Resource[] listResources(ResourceFilter filter)
Resource
Resource.listResources()
method, except
that the pathnames in the returned array must satisfy the filter.
If the given filter
is null
then all
pathnames are accepted. Otherwise, a pathname satisfies the filter
if and only if the value true
results when the
ResourceFilter.accept(Resource)
method of
the filter is invoked on the pathname.
listResources
in interface Resource
filter
- A resource filter
null
if this abstract pathname
does not denote a directory, or if an I/O error occurs.res.Resource#listResources(res.filter.ResourceFilter)
public String[] list(ResourceNameFilter filter)
Resource
Resource.list()
method, except that the strings in the
returned array must satisfy the filter. If the given
filter
is null
then all names are accepted.
Otherwise, a name satisfies the filter if and only if the value
true
results when the ResourceNameFilter.accept(railo.commons.io.res.Resource, java.lang.String)
method of the filter is invoked on this
abstract pathname and the name of a file or directory in the directory
that it denotes.
list
in interface Resource
filter
- A resourcename filter
filter
. The array will be empty if
the directory is empty or if no names were accepted by the
filter. Returns null
if this abstract pathname
does not denote a directory, or if an I/O error occurs.res.Resource#list(res.filter.ResourceNameFilter)
public Resource[] listResources(ResourceNameFilter filter)
Resource
Resource.listResources()
method, except
that the pathnames in the returned array must satisfy the filter.
If the given filter
is null
then all
pathnames are accepted. Otherwise, a pathname satisfies the filter
if and only if the value true
results when the
ResourceNameFilter.accept(railo.commons.io.res.Resource, java.lang.String)
method of the filter is
invoked on this abstract pathname and the name of a file or
directory in the directory that it denotes.
listResources
in interface Resource
filter
- A resourcename filter
null
if this abstract pathname
does not denote a directory, or if an I/O error occurs.res.Resource#listResources(res.filter.ResourceNameFilter)
public void moveTo(Resource dest) throws IOException
Resource
Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists.
moveTo
in interface Resource
dest
- The new abstract pathname for the named file
IOException
- throwed when operation not done sucessfullres.Resource#moveTo(res.Resource)
public InputStream getInputStream() throws IOException
getInputStream
in interface Resource
IOException
res.Resource#getInputStream()
public OutputStream getOutputStream() throws IOException
getOutputStream
in interface Resource
IOException
res.Resource#getOutputStream()
public OutputStream getOutputStream(boolean append) throws IOException
getOutputStream
in interface Resource
FileNotFoundException
IOException
Resource.getOutputStream(boolean)
public void createFile(boolean createParentWhenNotExists) throws IOException
Resource
createFile
in interface Resource
IOException
res.Resource#createFile(boolean)
public void remove(boolean alsoRemoveChildren) throws IOException
Resource
remove
in interface Resource
IOException
- if the file doesn't exists or can't deleteres.Resource#removeE(boolean)
public String getReal(String realpath)
Resource
getReal
in interface Resource
res.Resource#getReal(java.lang.String)
public Resource getRealResource(String realpath)
Resource
getRealResource
in interface Resource
res.Resource#getRealResource(java.lang.String)
public ContentType getContentType()
res.Resource#getContentType()
public void createDirectory(boolean createParentWhenNotExists) throws IOException
Resource
createDirectory
in interface Resource
createParentWhenNotExists
- throws Exception when can't create directory
IOException
res.Resource#createDirectory(boolean)
public ResourceProvider getResourceProvider()
getResourceProvider
in interface Resource
res.Resource#getResourceProvider()
public boolean isReadable()
Resource
isReadable
in interface Resource
true
if and only if the resource specified by this
abstract pathname exists and can be read by the
application; false
otherwiseres.Resource#isReadable()
public boolean isWriteable()
Resource
isWriteable
in interface Resource
true
if and only if the resource system actually
contains a resource denoted by this abstract pathname and
the application is allowed to write to the resource;
false
otherwise.res.Resource#isWriteable()
public boolean renameTo(Resource dest)
Resource
Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists.
renameTo
in interface Resource
dest
- The new abstract pathname for the named file
res.Resource#renameTo(res.Resource)
public boolean isArchive()
Resource
isArchive
in interface Resource
true
if and only if the file denoted by this
abstract pathname is a archiveResource.isArchive()
public boolean isSystem()
Resource
isSystem
in interface Resource
true
if and only if the file denoted by this
abstract pathname is a system resourceResource.isSystem()
public int getMode()
getMode
in interface Resource
Resource.getMode()
public void setMode(int mode) throws IOException
setMode
in interface Resource
IOException
public void setArchive(boolean value) throws IOException
Resource
setArchive
in interface Resource
IOException
- throwed when no access to change the value or the resource doesn't existsResource.setArchive(boolean)
public void setHidden(boolean value) throws IOException
Resource
setHidden
in interface Resource
IOException
- throwed when no access to change the value or the resource doesn't existsResource.setHidden(boolean)
public void setSystem(boolean value) throws IOException
Resource
setSystem
in interface Resource
IOException
- throwed when no access to change the value or the resource doesn't existsResource.setSystem(boolean)
public boolean setReadable(boolean value)
setReadable
in interface Resource
setReadable
in class File
IOException
Resource.setWritable(boolean)
public boolean setWritable(boolean value)
setWritable
in interface Resource
setWritable
in class File
public boolean createNewFile()
Resource
createNewFile
in interface Resource
createNewFile
in class File
true
if the named file does not exist and was
successfully created; false
if the named file
already existsFile.createNewFile()
public boolean canRead()
Resource
canRead
in interface Resource
canRead
in class File
true
if and only if the resource specified by this
abstract pathname exists and can be read by the
application; false
otherwiseFile.canRead()
public boolean canWrite()
Resource
canWrite
in interface Resource
canWrite
in class File
true
if and only if the resource system actually
contains a resource denoted by this abstract pathname and
the application is allowed to write to the resource;
false
otherwise.File.canWrite()
public boolean delete()
Resource
delete
in interface Resource
delete
in class File
File.delete()
public boolean exists()
Resource
exists
in interface Resource
exists
in class File
true
if and only if the resource denoted
by this abstract pathname exists; false
otherwiseFile.exists()
public boolean isAbsolute()
Resource
isAbsolute
in interface Resource
isAbsolute
in class File
true
if this abstract pathname is absolute,
false
otherwiseFile.isAbsolute()
public boolean isDirectory()
Resource
isDirectory
in interface Resource
isDirectory
in class File
true
if and only if the file denoted by this
abstract pathname exists and is a directory;
false
otherwiseFile.isDirectory()
public boolean isFile()
Resource
isFile
in interface Resource
isFile
in class File
true
if and only if the file denoted by this
abstract pathname exists and is a normal file;
false
otherwiseFile.isFile()
public boolean isHidden()
Resource
isHidden
in interface Resource
isHidden
in class File
true
if and only if the file denoted by this
abstract pathname is hiddenFile.isHidden()
public long lastModified()
Resource
lastModified
in interface Resource
lastModified
in class File
long
value representing the time the file was
last modified, measured in milliseconds since the epoch
(00:00:00 GMT, January 1, 1970), or 0L
if the
file does not exist or if an I/O error occursFile.lastModified()
public long length()
Resource
length
in interface Resource
length
in class File
0L
if the resource does not existFile.length()
public String[] list()
Resource
If this abstract pathname does not denote a directory, then this
method returns null
. Otherwise an array of strings is
returned, one for each file or directory in the directory. Names
denoting the directory itself and the directory's parent directory are
not included in the result. Each string is a file name rather than a
complete path.
There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
list
in interface Resource
list
in class File
null
if
this abstract pathname does not denote a directory, or if an
I/O error occurs.File.list()
public boolean mkdir()
Resource
mkdir
in interface Resource
mkdir
in class File
true
if and only if the directory was
created; false
otherwiseFile.mkdir()
public boolean mkdirs()
Resource
mkdirs
in interface Resource
mkdirs
in class File
true
if and only if the directory was created,
along with all necessary parent directories; false
otherwiseFile.mkdirs()
public boolean setLastModified(long time)
Resource
All platforms support file-modification times to the nearest second,
but some provide more precision. The argument will be truncated to fit
the supported precision. If the operation succeeds and no intervening
operations on the file take place, then the next invocation of the
method will return the (possibly
truncated) Resource.lastModified()
time
argument that was passed to this method.
setLastModified
in interface Resource
setLastModified
in class File
time
- The new last-modified time, measured in milliseconds since
the epoch (00:00:00 GMT, January 1, 1970)
true
if and only if the operation succeeded;
false
otherwiseFile.setLastModified(long)
public boolean setReadOnly()
Resource
setReadOnly
in interface Resource
setReadOnly
in class File
true
if and only if the operation succeeded;
false
otherwiseFile.setReadOnly()
public boolean getAttribute(short attribute)
Resource
getAttribute
in interface Resource
public void setAttribute(short attribute, boolean value) throws IOException
Resource
setAttribute
in interface Resource
attribute
- wich attrbute (Resource.ATTRIBUTE_*)
IOException
- throwed when no access to change the value,
when attributes are not supported or
the resource doesn't existspublic boolean equals(Object other)
equals
in class File
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |