/**
* 将本地文件上传到hdfs
* @throws IOException
* @throws InterruptedException
* @throws URISyntaxException
*/
@Test
public void testCopyFromLocalFile() throws IOException, InterruptedException, URISyntaxException {
// 1 获取文件系统
Configuration configuration = new Configuration();
configuration.set("dfs.replication", "2");
FileSystem fs = FileSystem.get(new URI("hdfs://192.168.2.210:9000"), configuration, "atguigu");
// 2 上传文件
fs.copyFromLocalFile(new Path("e:/keymap-shkstart.jar"), new Path("/keymap-shkstart.jar"));
// 3 关闭资源
fs.close();
System.out.println("over");
}