上传文件

package com.hadoop.hdfs;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class Client {
    public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException {

        //1. 获取fs对象
        Configuration conf=new Configuration();
        FileSystem fs=FileSystem.get(new URI("hdfs://localhost:9000"),conf,"root");

        //2. 执行上传API
        fs.copyFromLocalFile(new Path("e:/example.txt"),new Path("/example.txt"));

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

        System.out.println("over");
    }
}

 

上传文件

上一篇:Web For Pentester1 - Code injection


下一篇:无相劫指:Web安全之其他漏洞专题二-第八天