public static void main(String[] args) throws IOException {
System.setProperty("hadoop.home.dir", "d:/hadoop-common-2.2.0-bin/");
// 将本地文件上传到hdfs。
String target = "hdfs://10.108.66.81:9000/user/history/sample_data/tab1/tab3.csv";
FileInputStream fis = new FileInputStream(new File("D:\\temp\\tab2-2.csv"));// 读取本地文件
Configuration config = new Configuration();
FileSystem fs = FileSystem.get(URI.create(target), config);
OutputStream os = fs.create(new Path(target));
// copy
IOUtils.copyBytes(fis, os, 4096, true);
System.out.println("拷贝完成...");
}
################################################
FileSystem fs = FileSystem.get(URI.create(target), config);
修改为
FileSystem fs = FileSystem.get(URI.create(hdfs://10.108.66.81:9000), config);
#####################################################
|