HDFS修改文件名

   /**
     * 修改文件名
     * @throws IOException
     * @throws InterruptedException
     * @throws URISyntaxException
     */
    @Test
    public void testRename() throws IOException, InterruptedException, URISyntaxException{

        // 1 获取文件系统
        Configuration configuration = new Configuration();
        FileSystem fs = FileSystem.get(new URI("hdfs://192.168.2.210:9000"), configuration, "atguigu");

        // 2 修改文件名称
        fs.rename(new Path("/keymap-shkstart.jar"), new Path("/keymap-shkstart1.jar"));

        // 3 关闭资源
        fs.close();
    }

 

你可能感兴趣的:(HDFS)