1、Code -> GitHub
https://github.com/liufengji/hadoop_hdfs.git
2、Code
@Test
public void renameAtHDFS() throws Exception{
// 1 创建配置信息对象
Configuration configuration = new Configuration();
FileSystem fs = FileSystem.get(new URI("hdfs://node1:9000"),
configuration, "victor");
//2 重命名文件或文件夹
fs.rename(new Path("hdfs://node1:9000/user/victor/hello.txt"),
new Path("hdfs://node1:9000/user/victor/hellonihao.txt"));
// 3.关闭资源
fs.close();
}