Deleting a File
Function Description
Delete a specified file or folder from HDFS.
The deleted file or folder is stored in the .Trash/Current folder in the current user directory. If the file is deleted by mistake, you can restore it from this folder.
Sample Code
The following provides code snippets for deleting a file. For complete codes, see the HdfsMain class in com.huawei.bigdata.hdfs.examples.
/**
* Delete a file.
*
* @throws IOException
*/
private void delete() throws IOException {
Path beDeletedPath = new Path(DEST_PATH + File.separator + FILE_NAME);
fSystem.deleteOnExit(beDeletedPath);
System.out.println("succee to delete the file " + DEST_PATH
+ File.separator + FILE_NAME);
} Last Article: Reading a File
Next Article: Colocation
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.