/**
*上传文件,比较底层的写法
* @throws IOException
*/
@Test
public void shanchaung() throws IOException {
System.setProperty("HADOOP_USER_NAME","hadoop");
Configuration conf= new Configuration();
FileSystem fs=FileSystem.get(conf);
Path dst=new Path("hdfs://master:9000/user/hadoop/aa/qingshu4.txt");
FSDataOutputStream os=fs.create(dst);
FileInputStream is=new FileInputStream("c:/qingshu.txt");
IOUtils.copy(is,os);
}
/**
*上传文件,封装好的写法
* @throws IOException
*/
@Test
public void shanchuang2() throws IOException {
System.setProperty("HADOOP_USER_NAME","hadoop");
Configuration conf= new Configuration();
FileSystem fs=FileSystem.get(conf);
fs.copyFromLocalFile(new Path("c:/qingshu.txt"),new Path("hdfs://master:9000/aaa/bbb/ccc/qingshu2.txt"));
}