Mastering Hadoop 3
上QQ阅读APP看书,第一时间看更新

HDFS write 

The FileSystem class also provides a number of methods for creating a file. FileSystem has different overloaded versions of the create() method, and a few of them are given as follows:

public FSDataOutputStream create(Path f) throws IOException {
}

public FSDataOutputStream create(Path f, boolean overwrite) throws IOException {
}

public FSDataOutputStream create(Path f, Progressable progress) throws IOException {
}

public FSDataOutputStream create(Path f, short replication) throws IOException {
}

The first method is the simplest version to use, which uses a Path object so that a file is created and returns FSDataOutputStream. There are some other versions of this method as well, which allow us to overwrite an existing file, change the replication factor for a file, and change the block size and file permissions. The create() method with Progressable allows you to track the progress of data writes operations to a DataNode.