java.nio.file.spi
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractPath()
Initializes a new instance of this class. |
| Modifier and Type | Method and Description |
|---|---|
Path |
copyTo(Path target,
CopyOption... options)
Copy the file located by this path to a target location. |
Path |
createFile(FileAttribute<?>... attrs)
Creates a new and empty file, failing if the file already exists. |
void |
delete()
Deletes the file referenced by this object. |
boolean |
exists()
Tests whether the file located by this path exists. |
protected abstract void |
implCopyTo(Path target,
CopyOption... options)
Copy the file located by this path to a target location. |
protected abstract void |
implMoveTo(Path target,
CopyOption... options)
Move the file located by this path to a target location. |
Path |
moveTo(Path target,
CopyOption... options)
Move or rename the file located by this path to a target location. |
SeekableByteChannel |
newByteChannel(OpenOption... options)
Opens or creates a file, returning a seekable byte channel to access the file. |
DirectoryStream<Path> |
newDirectoryStream()
Opens the directory referenced by this object, returning a DirectoryStream to iterate over all entries in the directory. |
DirectoryStream<Path> |
newDirectoryStream(String glob)
Opens the directory referenced by this object, returning a DirectoryStream to iterate over the entries in the directory. |
InputStream |
newInputStream()
Opens the file located by this path for reading, returning an input stream to read bytes from the file. |
OutputStream |
newOutputStream(OpenOption... options)
Opens or creates the file located by this path for writing, returning an output stream to write bytes to the file. |
OutputStream |
newOutputStream(Set<? extends OpenOption> options,
FileAttribute<?>... attrs)
Opens or creates the file located by this path for writing, returning an output stream to write bytes to the file. |
boolean |
notExists()
Tests whether the file located by this path does not exist. |
WatchKey |
register(WatchService watcher,
WatchEvent.Kind<?>... events)
Registers the file located by this path with a watch service. |
| Methods inherited from class java.nio.file.Path |
|---|
compareTo, createDirectory, createLink, createSymbolicLink, delete, endsWith, equals, getFileSystem, getName, getName, getNameCount, getParent, getRoot, hashCode, isAbsolute, isHidden, iterator, newByteChannel, newDirectoryStream, normalize, readSymbolicLink, register, relativize, resolve, resolve, startsWith, subpath, toAbsolutePath, toRealPath, toString, toUri |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.nio.file.FileRef |
|---|
checkAccess, getFileAttributeView, getFileAttributeView, getFileStore, isSameFile |
| Constructor Detail |
|---|
AbstractPath
protected AbstractPath()
- Initializes a new instance of this class.
| Method Detail |
|---|
delete
public void delete()
throws IOException
- Deletes the file referenced by this object.
This method invokes the
delete(boolean)method with a parameter oftrue. It may be overridden where required. - Throws:
NoSuchFileException- If the file does not exist (optional specific exception)DirectoryNotEmptyException- If the file is a directory and could not otherwise be deleted because the directory is not empty (optional specific exception)IOException- If an I/O error occursSecurityException- In the case of the default provider, and a security manager is installed, theSecurityManager.checkDelete(String)method is invoked to check delete access to the file
createFile
public Path createFile(FileAttribute<?>... attrs) throws IOException
- Creates a new and empty file, failing if the file already exists.
This method invokes the
newByteChannel(Set,FileAttribute...)method to create the file. It may be overridden where required. - Specified by:
createFilein classPath
- Parameters:
attrs- an optional list of file attributes to set atomically when creating the file- Returns:
- this path
- Throws:
IllegalArgumentExceptionFileAlreadyExistsException- if a file of that name already exists (optional specific exception)IOException- if an I/O error occursSecurityException- In the case of the default provider, and a security manager is installed, thecheckWritemethod is invoked to check write access to the new file.
newByteChannel
public SeekableByteChannel newByteChannel(OpenOption... options) throws IOException
- Opens or creates a file, returning a seekable byte channel to access the
file.
This method invokes the
newByteChannel(Set,FileAttribute...)method to open or create the file. It may be overridden where required. - Specified by:
newByteChannelin interfaceFileRef- Specified by:
newByteChannelin classPath
- Parameters:
options- options specifying how the file is opened- Returns:
- a new seekable byte channel
- Throws:
IllegalArgumentException- if the set contains an invalid combination of optionsFileAlreadyExistsException- if a file of that name already exists and theCREATE_NEWoption is specified (optional specific exception)IOException- If an I/O error occursSecurityException- In the case of the default provider, and a security manager is installed, thecheckReadmethod is invoked to check read access to the path if the file is opened for reading. ThecheckWritemethod is invoked to check write access to the path if the file is opened for writing.
newInputStream
public InputStream newInputStream() throws IOException
- Opens the file located by this path for reading, returning an input
stream to read bytes from the file.
This method returns an
InputStreamthat is constructed by invoking theChannels.newInputStreammethod. It may be overridden where a more efficient implementation is available. - Specified by:
newInputStreamin classPath
- Returns:
- an input stream to read bytes from the file
- Throws:
IOException- if an I/O error occursSecurityException- In the case of the default provider, and a security manager is installed, thecheckReadmethod is invoked to check read access to the file.
newOutputStream
public OutputStream newOutputStream(OpenOption... options) throws IOException
- Opens or creates the file located by this path for writing, returning an
output stream to write bytes to the file.
This method returns an
OutputStreamthat is constructed by invoking theChannels.newOutputStreammethod. It may be overridden where a more efficient implementation is available. - Specified by:
newOutputStreamin classPath
- Parameters:
options- options specifying how the file is opened- Returns:
- a new seekable byte channel
- Throws:
IllegalArgumentException- ifoptionscontains an invalid combination of optionsIOException- if an I/O error occursSecurityException- In the case of the default provider, and a security manager is installed, thecheckWritemethod is invoked to check write access to the file.
newOutputStream
public OutputStream newOutputStream(Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
- Opens or creates the file located by this path for writing, returning an
output stream to write bytes to the file.
This method returns an
OutputStreamthat is constructed by invoking theChannels.newOutputStreammethod. It may be overridden where a more efficient implementation is available. - Specified by:
newOutputStreamin classPath
- Parameters:
options- options specifying how the file is openedattrs- an optional list of file attributes to set atomically when creating the file- Returns:
- a new output stream
- Throws:
IllegalArgumentException- if the set contains an invalid combination of optionsIOException- if an I/O error occursSecurityException- In the case of the default provider, and a security manager is installed, thecheckWritemethod is invoked to check write access to the file.
newDirectoryStream
public DirectoryStream<Path> newDirectoryStream() throws IOException
- Opens the directory referenced by this object, returning a
DirectoryStreamto iterate over all entries in the directory.This method invokes the
newDirectoryStream(Filter)method with a filter that accept all entries. It may be overridden where required. - Specified by:
newDirectoryStreamin classPath
- Returns:
- a new and open
DirectoryStreamobject - Throws:
NotDirectoryException- if the file could not otherwise be opened because it is not a directory (optional specific exception)IOException- if an I/O error occursSecurityException- In the case of the default provider, and a security manager is installed, thecheckReadmethod is invoked to check read access to the directory.
newDirectoryStream
public DirectoryStream<Path> newDirectoryStream(String glob) throws IOException
- Opens the directory referenced by this object, returning a
DirectoryStreamto iterate over the entries in the directory. The entries are filtered by matching theStringrepresentation of their file names against a given pattern.This method constructs a
PathMatcherby invoking the file system'sgetPathMatchermethod. This method may be overridden where a more efficient implementation is available. - Specified by:
newDirectoryStreamin classPath
- Parameters:
glob- the glob pattern- Returns:
- a new and open
DirectoryStreamobject - Throws:
PatternSyntaxException- if the pattern is invalidUnsupportedOperationException- if the pattern syntax is not known to the implementationNotDirectoryException- if the file could not otherwise be opened because it is not a directory (optional specific exception)IOException- if an I/O error occursSecurityException- In the case of the default provider, and a security manager is installed, thecheckReadmethod is invoked to check read access to the directory.
exists
public boolean exists()
- Tests whether the file located by this path exists.
This method invokes the
checkAccessmethod to check if the file exists. It may be overridden where a more efficient implementation is available. - Returns:
trueif the file exists;falseif the file does not exist or its existence cannot be determined.- See Also:
Path.notExists()
notExists
public boolean notExists()
- Tests whether the file located by this path does not exist.
This method invokes the
checkAccessmethod to check if the file exists. It may be overridden where a more efficient implementation is available. - Returns:
trueif the file does not exist;falseif the file exists or its existence cannot be determined.
register
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) throws IOException
- Registers the file located by this path with a watch service.
This method invokes the
register(WatchService,WatchEvent.Kind[],WatchEvent.Modifier...)method to register the file. It may be overridden where required. - Parameters:
watcher- The watch service to which this object is to be registeredevents- The events for which this object should be registered- Returns:
- A key representing the registration of this object with the given watch service
- Throws:
NotDirectoryException- If the file is registered to watch the entries in a directory and the file is not a directory (optional specific exception)IOException- If an I/O error occurs
implCopyTo
protected abstract void implCopyTo(Path target, CopyOption... options) throws IOException
- Copy the file located by this path to a target location.
This method is invoked by the
copyTomethod for the case that thisPathand the targetPathare associated with the same provider. - Parameters:
target- The target locationoptions- Options specifying how the copy should be done- Throws:
IllegalArgumentException- If an invalid option is specifiedFileAlreadyExistsException- The target file exists and cannot be replaced because theREPLACE_EXISTINGoption is not specified, or the target file is a non-empty directory (optional specific exception)IOException- If an I/O error occursSecurityException- In the case of the default provider, and a security manager is installed, thecheckReadmethod is invoked to check read access to the source file, thecheckWriteis invoked to check write access to the target file. If a symbolic link is copied the security manager is invoked to checkLinkPermission("symbolic").
implMoveTo
protected abstract void implMoveTo(Path target, CopyOption... options) throws IOException
- Move the file located by this path to a target location.
This method is invoked by the
moveTomethod for the case that thisPathand the targetPathare associated with the same provider. - Parameters:
target- The target locationoptions- Options specifying how the move should be done- Throws:
IllegalArgumentException- If an invalid option is specifiedFileAlreadyExistsException- The target file exists and cannot be replaced because theREPLACE_EXISTINGoption is not specified, or the target file is a non-empty directoryAtomicMoveNotSupportedException- The options array contains theATOMIC_MOVEoption but the file cannot be moved as an atomic file system operation.IOException- If an I/O error occursSecurityException- In the case of the default provider, and a security manager is installed, thecheckWritemethod is invoked to check write access to both the source and target file.
copyTo
public final Path copyTo(Path target, CopyOption... options) throws IOException
- Copy the file located by this path to a target location.
If this path is associated with the same
provideras thetargetthen theimplCopyTomethod is invoked to copy the file. Otherwise, this method attempts to copy the file to the target location in a manner that may be less efficient than would be the case that target is associated with the same provider as this path. - Parameters:
target- the target locationoptions- options specifying how the copy should be done- Returns:
- the target
- Throws:
IllegalArgumentExceptionFileAlreadyExistsException- if the target file exists and cannot be replaced because theREPLACE_EXISTINGoption is not specified, or the target file is a non-empty directory (optional specific exception)IOException- if an I/O error occursSecurityException- In the case of the default provider, and a security manager is installed, thecheckReadmethod is invoked to check read access to the source file, thecheckWriteis invoked to check write access to the target file. If a symbolic link is copied the security manager is invoked to checkLinkPermission("symbolic").
moveTo
public final Path moveTo(Path target, CopyOption... options) throws IOException
- Move or rename the file located by this path to a target location.
If this path is associated with the same
provideras thetargetthen theimplMoveTomethod is invoked to move the file. Otherwise, this method attempts to copy the file to the target location and delete the source file. This implementation may be less efficient than would be the case that target is associated with the same provider as this path. - Parameters:
target- the target locationoptions- options specifying how the move should be done- Returns:
- the target
- Throws:
IllegalArgumentExceptionFileAlreadyExistsException- if the target file exists and cannot be replaced because theREPLACE_EXISTINGoption is not specified, or the target file is a non-empty directoryIOException- if an I/O error occursSecurityException- In the case of the default provider, and a security manager is installed, thecheckWritemethod is invoked to check write access to both the source and target file.
|
Java™ Platform Standard Ed. 7 DRAFT ea-b59 |
|||||||||
| PREV CLASS NEXT CLASS | NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
