HDFS -- how to delete files from HDFS

Source: Internet
Author: User
Tags hadoop fs

You can use the command line bin/Hadoop fs-rm (r) to delete files (folders) on hdfs)

You can also use HDFS APIs. As follows:

Import java.net. URI;
Import org. apache. hadoop. conf. Configuration;
Import org. apache. hadoop. fs. FileSystem;
Import org. apache. hadoop. fs. Path;
Public class FileDelete
{
Public static void main (String [] args) throws Exception
{
If (args. length! = 1 ){
System. out. println ("Usage filedelete <target> ");
System. exit (1 );
}
Configuration conf = new Configuration ();
FileSystem hdfs = FileSystem. get (URI. create (args [0]), conf );
Hdfs. delete (new Path (args [0]), false );
}
}

Copy local files to HDFS

Download files from HDFS to local

Upload local files to HDFS

Common commands for HDFS basic files

Introduction to HDFS and MapReduce nodes in Hadoop

Hadoop practice Chinese version + English version + Source Code [PDF]

Hadoop: The Definitive Guide (PDF]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.