public class FileContext.Util extends Object
Constructor and Description |
---|
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 Util()
public boolean exists(Path f) throws org.apache.hadoop.security.AccessControlException, UnsupportedFileSystemException, IOException
f
- the file or dir to be checkedorg.apache.hadoop.security.AccessControlException
- 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 org.apache.hadoop.security.AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException
ContentSummary
of path f.f
- pathContentSummary
of path f.org.apache.hadoop.security.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 org.apache.hadoop.security.AccessControlException, FileNotFoundException, IOException
org.apache.hadoop.security.AccessControlException
FileNotFoundException
IOException
public FileStatus[] listStatus(Path f, PathFilter filter) throws org.apache.hadoop.security.AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException
f
- is the path namefilter
- is the user-supplied path filterorg.apache.hadoop.security.AccessControlException
- 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 org.apache.hadoop.security.AccessControlException, FileNotFoundException, IOException
files
- is a list of pathsfilter
- is the filterorg.apache.hadoop.security.AccessControlException
- 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 org.apache.hadoop.security.AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException
f
- is the pathorg.apache.hadoop.security.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 RemoteIterator<LocatedFileStatus> listFiles(Path f, boolean recursive) throws org.apache.hadoop.security.AccessControlException, FileNotFoundException, UnsupportedFileSystemException, IOException
f
- is the pathrecursive
- if the subdirectories need to be traversed recursivelyorg.apache.hadoop.security.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[] globStatus(Path pathPattern) throws org.apache.hadoop.security.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 patternorg.apache.hadoop.security.AccessControlException
- 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 org.apache.hadoop.security.AccessControlException, UnsupportedFileSystemException, IOException
pathPattern
- regular expression specifying the path patternfilter
- user-supplied path filterorg.apache.hadoop.security.AccessControlException
- 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 org.apache.hadoop.security.AccessControlException, FileAlreadyExistsException, FileNotFoundException, ParentNotDirectoryException, UnsupportedFileSystemException, IOException
copy(Path, Path, boolean, boolean)
org.apache.hadoop.security.AccessControlException
FileAlreadyExistsException
FileNotFoundException
ParentNotDirectoryException
UnsupportedFileSystemException
IOException
public boolean copy(Path src, Path dst, boolean deleteSource, boolean overwrite) throws org.apache.hadoop.security.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.org.apache.hadoop.security.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 © 2018 Apache Software Foundation. All Rights Reserved.