MAPREDUCE服务 MRS-删除HDFS指定文件:代码样例

时间:2024-10-18 17:22:32

代码样例

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

 /**
 * 删除文件
 *
 * @throws java.io.IOException
 */
private void delete() throws IOException {
    Path beDeletedPath = new Path(DEST_PATH + File.separator + FILE_NAME);
    if (fSystem.delete(beDeletedPath, true)) {
         LOG .info("success to delete the file " + DEST_PATH + File.separator + FILE_NAME);
    } else {
        LOG.warn("failed to delete the file " + DEST_PATH + File.separator + FILE_NAME);
    }
}
support.huaweicloud.com/devg3-mrs/mrs_07_300017.html