@Internal public class LocalFileSystem extends FileSystem
LocalFile provides an implementation of the FileSystem interface for the local file
system.FileSystem.FSKey, FileSystem.WriteMode| Constructor and Description |
|---|
LocalFileSystem()
Constructs a new
LocalFileSystem object. |
| Modifier and Type | Method and Description |
|---|---|
FSDataOutputStream |
create(Path f,
boolean overwrite)
Opens an FSDataOutputStream at the indicated Path.
|
FSDataOutputStream |
create(Path f,
boolean overwrite,
int bufferSize,
short replication,
long blockSize)
Opens an FSDataOutputStream at the indicated Path.
|
boolean |
delete(Path f,
boolean recursive)
Delete a file.
|
BlockLocation[] |
getFileBlockLocations(FileStatus file,
long start,
long len)
Return an array containing hostnames, offset and size of
portions of the given file.
|
FileStatus |
getFileStatus(Path f)
Return a file status object that represents the path.
|
Path |
getHomeDirectory()
Returns the path of the user's home directory in this file system.
|
URI |
getUri()
Returns a URI whose scheme and authority identify this file system.
|
Path |
getWorkingDirectory()
Returns the path of the file system's current working directory.
|
void |
initialize(URI name)
Called after a new FileSystem instance is constructed.
|
boolean |
isDistributedFS()
Returns true if this is a distributed file system, false otherwise.
|
FileStatus[] |
listStatus(Path f)
List the statuses of the files/directories in the given path if the path is
a directory.
|
boolean |
mkdirs(Path f)
Recursively creates the directory specified by the provided path.
|
FSDataInputStream |
open(Path f)
Opens an FSDataInputStream at the indicated Path.
|
FSDataInputStream |
open(Path f,
int bufferSize)
Opens an FSDataInputStream at the indicated Path.
|
boolean |
rename(Path src,
Path dst)
Renames the file/directory src to dst.
|
exists, get, getDefaultBlockSize, getLocalFileSystem, initOutPathDistFS, initOutPathLocalFS, isFlinkSupportedScheme, setDefaultSchemepublic LocalFileSystem()
LocalFileSystem object.public BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len) throws IOException
FileSystemgetFileBlockLocations in class FileSystemIOExceptionpublic FileStatus getFileStatus(Path f) throws IOException
FileSystemgetFileStatus in class FileSystemf - The path we want information fromFileNotFoundException - when the path does not exist;
IOException see specific implementationIOExceptionpublic URI getUri()
FileSystemgetUri in class FileSystempublic Path getWorkingDirectory()
FileSystemgetWorkingDirectory in class FileSystempublic Path getHomeDirectory()
FileSystemgetHomeDirectory in class FileSystempublic void initialize(URI name) throws IOException
FileSysteminitialize in class FileSystemname - a URI whose authority section names the host, port, etc. for this file systemIOExceptionpublic FSDataInputStream open(Path f, int bufferSize) throws IOException
FileSystemopen in class FileSystemf - the file name to openbufferSize - the size of the buffer to be used.IOExceptionpublic FSDataInputStream open(Path f) throws IOException
FileSystemopen in class FileSystemf - the file to openIOExceptionpublic FileStatus[] listStatus(Path f) throws IOException
FileSystemlistStatus in class FileSystemf - given pathIOExceptionpublic boolean delete(Path f, boolean recursive) throws IOException
FileSystemdelete in class FileSystemf - the path to deleterecursive - if path is a directory and set to true, the directory is deleted else throws an exception. In
case of a file the recursive can be set to either true or falsetrue if delete is successful, false otherwiseIOExceptionpublic boolean mkdirs(Path f) throws IOException
mkdirs in class FileSystemf - the directory/directories to be createdtrueif the directories either already existed or have been created successfully,
false otherwiseIOException - thrown if an error occurred while creating the directory/directoriespublic FSDataOutputStream create(Path f, boolean overwrite, int bufferSize, short replication, long blockSize) throws IOException
FileSystemcreate in class FileSystemf - the file name to openoverwrite - if a file with this name already exists, then if true,
the file will be overwritten, and if false an error will be thrown.bufferSize - the size of the buffer to be used.replication - required block replication for the file.blockSize - the size of the file blocksIOExceptionpublic FSDataOutputStream create(Path f, boolean overwrite) throws IOException
FileSystemcreate in class FileSystemf - the file name to openoverwrite - if a file with this name already exists, then if true,
the file will be overwritten, and if false an error will be thrown.IOExceptionpublic boolean rename(Path src, Path dst) throws IOException
FileSystemrename in class FileSystemsrc - the file/directory to renamedst - the new name of the file/directorytrue if the renaming was successful, false otherwiseIOExceptionpublic boolean isDistributedFS()
FileSystemisDistributedFS in class FileSystemCopyright © 2014–2016 The Apache Software Foundation. All rights reserved.