更新时间:2022-11-14 10:35:14 来源:极悦 浏览771次
命令是
hadoop fs -copyFromLocal
package com.amal.hadoop;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
/**
* @author amalgjose
*
*/
public class CopyFromLocal {
public static void main(String[] args) throws IOException {
Configuration conf =new Configuration();
conf.addResource(new Path("conf/core-site.xml"));
conf.addResource(new Path("conf/mapred-site.xml"));
conf.addResource(new Path("conf/hdfs=site.xml"));
FileSystem fs = FileSystem.get(conf);
Path sourcePath = new Path("source");
Path destPath = new Path("/user/training");
if(!(fs.exists(destPath)))
{
System.out.println("No Such destination exists :"+destPath);
return;
}
fs.copyFromLocalFile(sourcePath, destPath);
}
}
命令是
hadoop fs -copyToLocal
package com.amal.hadoop;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
/**
* @author amalgjose
*
*/
public class CopyToLocal {
public static void main(String[] args) throws IOException {
Configuration conf =new Configuration();
conf.addResource(new Path("conf/core-site.xml"));
conf.addResource(new Path("conf/mapred-site.xml"));
conf.addResource(new Path("conf/hdfs=site.xml"));
FileSystem fs = FileSystem.get(conf);
Path sourcePath = new Path("/user/training");
Path destPath = new Path("destination");
if(!(fs.exists(sourcePath)))
{
System.out.println("No Such Source exists :"+sourcePath);
return;
}
fs.copyToLocalFile(sourcePath, destPath);
}
}
0基础 0学费 15天面授
Java就业班有基础 直达就业
业余时间 高薪转行
Java在职加薪班工作1~3年,加薪神器
工作3~5年,晋升架构
提交申请后,顾问老师会电话与您沟通安排学习