Help Center/
MapReduce Service/
Developer Guide (LTS)/
HDFS Development Guide (Normal Mode)/
Developing the Project/
Declare the Example Codes/
Deleting a File
Updated on 2022-07-11 GMT+08:00
Deleting a File
Function
Delete a file from the Hadoop distributed file system (HDFS).
Exercise caution when you delete files because the deletion is irreversible.
Example Codes
The following is code snippets. 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); 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); } }
Parent topic: Declare the Example Codes
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.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot