Hadoop copy a directory?

rakeshr picture rakeshr · Jan 17, 2011 · Viewed 72.1k times · Source

Is there an HDFS API that can copy an entire local directory to the HDFS? I found an API for copying files but is there one for directories?

Answer

Spike Gronim picture Spike Gronim · Jan 17, 2011

Use the Hadoop FS shell. Specifically:

$ hadoop fs -copyFromLocal /path/to/local hdfs:///path/to/hdfs

If you want to do it programmatically, create two FileSystems (one Local and one HDFS) and use the FileUtil class