Deleting an HDFS 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("succeed to delete the file " + DEST_PATH + File.separator + FILE_NAME); }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot