连接hdfs
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
public class java_hdfs {
//自定义文件系统,类变量
FileSystem fs=null;
//预处理,@Test之前
@Before
public void inint() throws URISyntaxException, IOException, InterruptedException {
fs=FileSystem.get(new URI("hdfs://192.168.18.129:9000"),new Configuration(),"root");
}
}
测试
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import