更新時(shí)間:2022-11-14 10:35:14 來源:動(dòng)力節(jié)點(diǎn) 瀏覽1099次
命令是
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);
}
}
相關(guān)閱讀
0基礎(chǔ) 0學(xué)費(fèi) 15天面授
有基礎(chǔ) 直達(dá)就業(yè)
業(yè)余時(shí)間 高薪轉(zhuǎn)行
工作1~3年,加薪神器
工作3~5年,晉升架構(gòu)
提交申請(qǐng)后,顧問老師會(huì)電話與您溝通安排學(xué)習(xí)
初級(jí) 202925
初級(jí) 203221
初級(jí) 202629
初級(jí) 203743