public class FileContext.Util extends Object
Constructor and Description |
---|
FileContext.Util() |
Modifier and Type | Method and Description |
---|---|
boolean |
copy(Path src,
Path dst)
Copy file from src to dest.
|
boolean |
copy(Path src,
Path dst,
boolean deleteSource,
boolean overwrite)
Copy from src to dst, optionally deleting src and overwriting dst.
|
boolean |
exists(Path f)
Does the file exist?
Note: Avoid using this method if you already have FileStatus in hand.
|
ContentSummary |
getContentSummary(Path f)
Return the
ContentSummary of path f. |
FileStatus[] |
globStatus(Path pathPattern)
Return all the files that match filePattern and are not checksum
files.
|
FileStatus[] |
globStatus(Path pathPattern,
PathFilter filter)
Return an array of FileStatus objects whose path names match pathPattern
and is accepted by the user-supplied path filter.
|
RemoteIterator<LocatedFileStatus> |
listFiles(Path f,
boolean recursive)
List the statuses and block locations of the files in the given path.
|
FileStatus[] |
listStatus(Path f)
List the statuses of the files/directories in the given path
if the path is a directory.
|
FileStatus[] |
listStatus(Path[] files)
|
FileStatus[] |
listStatus(Path[] files,
PathFilter filter)
Filter files/directories in the given list of paths using user-supplied
path filter.
|
FileStatus[] |
listStatus(Path f,
PathFilter filter)
Filter files/directories in the given path using the user-supplied path
filter.
|
public FileContext.Util()
public boolean exists(Path f) throws AccessControlException, UnsupportedFileSystemException, IOException
f
- the file or dir to be checkedAccessControlException
- If access is deniedIOException
- If an I/O error occurredUnsupportedFileSystemException
- If file system for f
is
not supported
Exceptions applicable to file systems accessed over RPC:RpcClientException
- If an exception occurred in the RPC clientRpcServerException
- If an exception occurred in the RPC serverUnexpectedServerException
- If server implementation throws
undeclared exception to RPC serverpublic ContentSummary getContentSummary(Path f) throws AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException
ContentSummary
of path f.f
- pathContentSummary
of path f.AccessControlException
- If access is deniedFileNotFoundException
- If f
does not existUnsupportedFileSystemException
- If file system for
f
is not supportedIOException
- If an I/O error occurred
Exceptions applicable to file systems accessed over RPC:RpcClientException
- If an exception occurred in the RPC clientRpcServerException
- If an exception occurred in the RPC serverUnexpectedServerException
- If server implementation throws
undeclared exception to RPC serverpublic FileStatus[] listStatus(Path[] files) throws AccessControlException, FileNotFoundException, IOException
public FileStatus[] listStatus(Path f, PathFilter filter) throws AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException
f
- is the path namefilter
- is the user-supplied path filterAccessControlException
- If access is deniedFileNotFoundException
- If f
does not existUnsupportedFileSystemException
- If file system for
pathPattern
is not supportedIOException
- If an I/O error occurred
Exceptions applicable to file systems accessed over RPC:RpcClientException
- If an exception occurred in the RPC clientRpcServerException
- If an exception occurred in the RPC serverUnexpectedServerException
- If server implementation throws
undeclared exception to RPC serverpublic FileStatus[] listStatus(Path[] files, PathFilter filter) throws AccessControlException, FileNotFoundException, IOException
files
- is a list of pathsfilter
- is the filterAccessControlException
- If access is deniedFileNotFoundException
- If a file in files
does not
existIOException
- If an I/O error occurred
Exceptions applicable to file systems accessed over RPC:RpcClientException
- If an exception occurred in the RPC clientRpcServerException
- If an exception occurred in the RPC serverUnexpectedServerException
- If server implementation throws
undeclared exception to RPC serverpublic FileStatus[] listStatus(Path f) throws AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException
f
- is the pathAccessControlException
- If access is deniedFileNotFoundException
- If f
does not existUnsupportedFileSystemException
- If file system for f
is
not supportedIOException
- If an I/O error occurred
Exceptions applicable to file systems accessed over RPC:RpcClientException
- If an exception occurred in the RPC clientRpcServerException
- If an exception occurred in the RPC serverUnexpectedServerException
- If server implementation throws
undeclared exception to RPC serverpublic RemoteIterator<LocatedFileStatus> listFiles(Path f, boolean recursive) throws AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException
f
- is the pathrecursive
- if the subdirectories need to be traversed recursivelyAccessControlException
- If access is deniedFileNotFoundException
- If f
does not existUnsupportedFileSystemException
- If file system for f
is not supportedIOException
- If an I/O error occurred
Exceptions applicable to file systems accessed over RPC:RpcClientException
- If an exception occurred in the RPC clientRpcServerException
- If an exception occurred in the RPC serverUnexpectedServerException
- If server implementation throws
undeclared exception to RPC serverpublic FileStatus[] globStatus(Path pathPattern) throws AccessControlException, UnsupportedFileSystemException, IOException
Return all the files that match filePattern and are not checksum files. Results are sorted by their names.
A filename pattern is composed of regular characters and special pattern matching characters, which are:
pathPattern
- a regular expression specifying a pth patternAccessControlException
- If access is deniedUnsupportedFileSystemException
- If file system for
pathPattern
is not supportedIOException
- If an I/O error occurred
Exceptions applicable to file systems accessed over RPC:RpcClientException
- If an exception occurred in the RPC clientRpcServerException
- If an exception occurred in the RPC serverUnexpectedServerException
- If server implementation throws
undeclared exception to RPC serverpublic FileStatus[] globStatus(Path pathPattern, PathFilter filter) throws AccessControlException, UnsupportedFileSystemException, IOException
pathPattern
- regular expression specifying the path patternfilter
- user-supplied path filterAccessControlException
- If access is deniedUnsupportedFileSystemException
- If file system for
pathPattern
is not supportedIOException
- If an I/O error occurred
Exceptions applicable to file systems accessed over RPC:RpcClientException
- If an exception occurred in the RPC clientRpcServerException
- If an exception occurred in the RPC serverUnexpectedServerException
- If server implementation throws
undeclared exception to RPC serverpublic boolean copy(Path src, Path dst) throws AccessControlException, FileAlreadyExistsException, FileNotFoundException, ParentNotDirectoryException, UnsupportedFileSystemException, IOException
copy(Path, Path, boolean, boolean)
public boolean copy(Path src, Path dst, boolean deleteSource, boolean overwrite) throws AccessControlException, FileAlreadyExistsException, FileNotFoundException, ParentNotDirectoryException, UnsupportedFileSystemException, IOException
src
- dst
- deleteSource
- - delete src if trueoverwrite
- overwrite dst if true; throw IOException if dst exists
and overwrite is false.AccessControlException
- If access is deniedFileAlreadyExistsException
- If dst
already existsFileNotFoundException
- If src
does not existParentNotDirectoryException
- If parent of dst
is not
a directoryUnsupportedFileSystemException
- If file system for
src
or dst
is not supportedIOException
- If an I/O error occurred
Exceptions applicable to file systems accessed over RPC:RpcClientException
- If an exception occurred in the RPC clientRpcServerException
- If an exception occurred in the RPC serverUnexpectedServerException
- If server implementation throws
undeclared exception to RPC server
RuntimeExceptions:InvalidPathException
- If path dst
is invalidCopyright © 2017 Apache Software Foundation. All Rights Reserved.