public class FileResource extends Object implements Resource
| Constructor and Description |
|---|
FileResource(File file) |
FileResource(String file) |
| Modifier and Type | Method and Description |
|---|---|
Resource |
copy(Resource destination)
Copy a file/directory to destination;
|
boolean |
delete()
Deletes the file resource.
|
boolean |
exists()
Check if this file resource exists.
|
String |
getAbsolutePath()
Returns the absolute file resource string of this
|
File |
getFile() |
String |
getName()
Returns the name of this file resource
|
Resource |
getParent()
Returns the file resource of this parent, or
null if this file resource does not name a parent directory. |
boolean |
isDirectory()
Check if the file denoted is a directory.
|
boolean |
isLeaf()
Return true if this file resource is a file, not a directory.
|
boolean |
isSymbolicLink()
Return true if this resource is a symbolic link.
|
long |
lastAccessed()
Returns the last accessed time of the file or directory
|
long |
lastModified()
Returns the last modified time of the file or directory
|
List<Resource> |
list()
Returns a list of file resources denoting the files in the
directory denoted by this file resource.
|
List<Resource> |
list(ResourceFilter filter)
Returns a list of path names denoting the files in the
directory denoted by this file resource filtered by argument.
|
List<Resource> |
listRoots()
List the available filesystem roots.
|
boolean |
mkdirs()
Creates the directory named by this file resource, including any
necessary but nonexistent parent directories.
|
void |
move(Resource target)
Move a file/directory.
|
Resource |
newInstance(String path)
Return a new instance of FileResource with String as argument
|
InputStream |
read()
InputStream from this FileResource
|
<A extends BasicFileAttributes> |
readAttributes(Class<A> type,
LinkOption... options) |
Resource |
readSymbolicLink()
If the Resource system support symbolic links and
this is a symbolic link, return the link target.
|
List<Resource> |
resolve(Resource cwd)
Resolve a file that might contain (~,*,?) based on this instance and
a given current working directory as argument.
|
void |
setLastAccessed(long time)
Sets the last-accessed time of the file or directory named by this abstract pathname.
|
boolean |
setLastModified(long time)
Sets the last-modified time of the file or directory named by this abstract pathname.
|
String |
toString() |
OutputStream |
write(boolean append)
OutputStream that will be written to this FileResource
|
public FileResource(File file)
public FileResource(String file)
public String getName()
Resourcepublic String getAbsolutePath()
ResourcegetAbsolutePath in interface Resourcepublic boolean isLeaf()
Resourcepublic boolean isDirectory()
ResourceisDirectory in interface Resourcepublic boolean isSymbolicLink()
ResourceisSymbolicLink in interface Resourcepublic Resource readSymbolicLink() throws IOException
ResourcereadSymbolicLink in interface ResourceIOExceptionpublic boolean exists()
Resourcepublic boolean mkdirs()
Resourcepublic boolean delete()
Resourcepublic void move(Resource target) throws IOException
Resourcemove in interface Resourcetarget - the target file/directory.IOExceptionpublic Resource getParent()
Resourcenull if this file resource does not name a parent directory.public List<Resource> list()
Resourcepublic List<Resource> list(ResourceFilter filter)
Resourcepublic List<Resource> listRoots()
Resourcepublic List<Resource> resolve(Resource cwd)
Resourcepublic InputStream read() throws FileNotFoundException
Resourceread in interface ResourceFileNotFoundException - if the file doesn't existpublic <A extends BasicFileAttributes> A readAttributes(Class<A> type, LinkOption... options) throws IOException
readAttributes in interface ResourceIOExceptionpublic OutputStream write(boolean append) throws FileNotFoundException
Resourcewrite in interface ResourceFileNotFoundException - if file cannot be written to or is !isLeaf()public Resource newInstance(String path)
ResourcenewInstance in interface Resourcepath - argumentpublic Resource copy(Resource destination) throws IOException
Resourcecopy in interface Resourcedestination - local that you want copy fileIOExceptionpublic boolean setLastModified(long time)
ResourcesetLastModified in interface Resourcetime - The new last-modified time, measured in millisecondspublic long lastModified()
ResourcelastModified in interface Resourcepublic void setLastAccessed(long time)
throws IOException
ResourcesetLastAccessed in interface Resourcetime - The new last-accessed time, measured in millisecondsIOExceptionpublic long lastAccessed()
throws IOException
ResourcelastAccessed in interface ResourceIOExceptionpublic File getFile()
Copyright © 2018 JBoss by Red Hat. All rights reserved.