public interface Location
Location is agnostic to the type of file system the resource is on.
| Modifier and Type | Field and Description |
|---|---|
static String |
TEMP_FILE_SUFFIX
Suffix added to every temp file name generated with
getTempFile(String). |
| Modifier and Type | Method and Description |
|---|---|
Location |
append(String child)
Appends the child to the current
Location. |
boolean |
createNew()
Atomically 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 file or directory denoted by this abstract pathname.
|
boolean |
delete(boolean recursive)
Deletes the file or directory denoted by this abstract pathname.
|
boolean |
exists()
Checks if the this location exists.
|
InputStream |
getInputStream() |
LocationFactory |
getLocationFactory()
Returns the location factory used to create this instance.
|
String |
getName() |
OutputStream |
getOutputStream() |
OutputStream |
getOutputStream(String permission)
Creates an
OutputStream for this location with the given permission. |
Location |
getTempFile(String suffix)
Returns unique location for temporary file to be placed near this location.
|
boolean |
isDirectory()
Checks if this location represents a directory.
|
long |
lastModified() |
long |
length() |
List<Location> |
list()
List the locations under this location.
|
boolean |
mkdirs()
Creates the directory named by this abstract pathname, including any necessary
but nonexistent parent directories.
|
Location |
renameTo(Location destination)
Moves the file or directory denoted by this abstract pathname.
|
URI |
toURI() |
static final String TEMP_FILE_SUFFIX
getTempFile(String).boolean exists()
throws IOException
IOExceptionString getName()
boolean createNew()
throws IOException
true if the file is successfully create, false otherwise.IOExceptionInputStream getInputStream() throws IOException
InputStream for this location.IOExceptionOutputStream getOutputStream() throws IOException
OutputStream for this location.IOExceptionOutputStream getOutputStream(String permission) throws IOException
OutputStream for this location with the given permission. The actual permission supported
depends on implementation.permission - A POSIX permission string.OutputStream for writing to this location.IOException - If failed to create the OutputStream.Location append(String child) throws IOException
Location.
Returns a new instance of Location.
child - to be appended to this location.LocationIOExceptionLocation getTempFile(String suffix) throws IOException
suffix - part of the file name to include in the temp file nameIOExceptionboolean delete()
throws IOException
IOExceptionboolean delete(boolean recursive)
throws IOException
recursive is true, then content of the
directory will be deleted recursively, otherwise the directory must be empty in order to be deleted.
Note that when calling this method with recursive = true for a directory, any
failure during deletion will have some entries inside the directory being deleted while some are not.recursive - Indicate if recursively delete a directory. Ignored if the pathname represents a file.IOException@Nullable Location renameTo(Location destination) throws IOException
destination - destination locationIOExceptionboolean mkdirs()
throws IOException
IOExceptionlong length()
throws IOException
IOExceptionlong lastModified()
throws IOException
IOExceptionboolean isDirectory()
throws IOException
true if it is a directory, false otherwise.IOExceptionList<Location> list() throws IOException
IOExceptionLocationFactory getLocationFactory()
LocationFactory instance for creating this instance.Copyright © 2013-2015 The Apache Software Foundation. All rights reserved.