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()
Resource
public String getAbsolutePath()
Resource
getAbsolutePath
in interface Resource
public boolean isLeaf()
Resource
public boolean isDirectory()
Resource
isDirectory
in interface Resource
public boolean isSymbolicLink()
Resource
isSymbolicLink
in interface Resource
public Resource readSymbolicLink() throws IOException
Resource
readSymbolicLink
in interface Resource
IOException
public boolean exists()
Resource
public boolean mkdirs()
Resource
public boolean delete()
Resource
public void move(Resource target) throws IOException
Resource
move
in interface Resource
target
- the target file/directory.IOException
public Resource getParent()
Resource
null
if this file resource does not name a parent directory.public List<Resource> list()
Resource
public List<Resource> list(ResourceFilter filter)
Resource
public List<Resource> listRoots()
Resource
public List<Resource> resolve(Resource cwd)
Resource
public InputStream read() throws FileNotFoundException
Resource
read
in interface Resource
FileNotFoundException
- if the file doesn't existpublic <A extends BasicFileAttributes> A readAttributes(Class<A> type, LinkOption... options) throws IOException
readAttributes
in interface Resource
IOException
public OutputStream write(boolean append) throws FileNotFoundException
Resource
write
in interface Resource
FileNotFoundException
- if file cannot be written to or is !isLeaf()public Resource newInstance(String path)
Resource
newInstance
in interface Resource
path
- argumentpublic Resource copy(Resource destination) throws IOException
Resource
copy
in interface Resource
destination
- local that you want copy fileIOException
public boolean setLastModified(long time)
Resource
setLastModified
in interface Resource
time
- The new last-modified time, measured in millisecondspublic long lastModified()
Resource
lastModified
in interface Resource
public void setLastAccessed(long time) throws IOException
Resource
setLastAccessed
in interface Resource
time
- The new last-accessed time, measured in millisecondsIOException
public long lastAccessed() throws IOException
Resource
lastAccessed
in interface Resource
IOException
public File getFile()
Copyright © 2019 JBoss, a division of Red Hat, Inc.. All Rights Reserved.