Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move files to HDFS using Java

How can I execute hadoop put files in hdfs using Java? That's possible?

Using this statement:

public abstract boolean rename(Path src, Path dst) throws IOException

?

Thanks!

like image 213
Pedro Alves Avatar asked Jan 01 '26 18:01

Pedro Alves


1 Answers

You should be able to use copyFromLocalFile:

Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
Path localPath = new Path("path/to/local/file");
Path hdfsPath = new Path("/path/in/hdfs");
fs.copyFromLocalFile(localPath, hdfsPath);
like image 163
Dan W Avatar answered Jan 03 '26 10:01

Dan W



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!