MapReduce服务 MRS-追加文件内容:代码样例

时间:2023-11-01 16:19:45

代码样例

如下是代码片段,详细代码请参考com.huawei.bigdata.hdfs.examples中的HdfsExample类。

/** * 追加文件内容 * * @throws java.io.IOException */private void append() throws IOException {    final String content = "I append this content.";    FSDataOutputStream out = null;    try {        out = fSystem.append(new Path(DEST_PATH + File.separator + FILE_NAME));        out.write(content.getBytes());        out.hsync();        LOG.info("success to append.");    } finally {        // make sure the stream is closed finally.        IOUtils.closeStream(out);    }}
support.huaweicloud.com/devg3-mrs/mrs_07_300015.html