hdpuser222
hdpuser222

Reputation: 11

Hadoop Java - copy file from windows share folder server to HDFS

I want upload multiple file from Windows share folder server (e.g. //server_name/folder/) to my HDFS using Java

list of methods I have tried

Do I need to create FTP or How about using FTPFileSystem?

Or anyone have better solution Or Sample Code

thank you

Upvotes: 0

Views: 1012

Answers (1)

leftjoin
leftjoin

Reputation: 38290

FileSystem has copyFromLocal method:

import org.apache.hadoop.conf.Configuration; 
import org.apache.hadoop.fs.FileSystem;

Configuration configuration = new Configuration();
configuration.set("fs.defaultFS", "hdfs://abc:9000");

FileSystem fs= FileSystem.get(configuration);
fs.copyFromLocalFile(new Path("/source/directory/"), 
  new Path("/user/hadoop/dir"));

Upvotes: 1

Related Questions