代码如下:
package com.hadoop.cluster;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
public class HdfsOps {
public static void main(String[] args) throws Exception {
WriteHdfs();
}
public static void WriteHdfs() throws Exception{
Configuration configuration = new Configuration();
FileSystem fSystem = FileSystem.get(configuration);
Path path = new Path("hdfs://namenode:8020/data/test.txt");
FSDataOutputStream stream = fSystem.create(path);
stream.write("test hdfs api write".getBytes());
stream.close();
}
}
运行过程报如下错误:
Exception in thread "main" java.lang.IllegalAr