参考链接:
- https://www.cnblogs.com/shoufeng/p/14461706.html
hdfs写文件示例代码
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(file), conf);
Path path = new Path(file);
FSDataOutputStream out = fs.create(path); //创建文件
out.write(“hello”.getBytes("UTF-8"));
out.close();
out.write(“hello”.getBytes(“UTF-8”));
FSDataOutputStream 的 write 方法先是调用父类FilterOutputStream write方法
//FilterOutputStream
public void write(byte b[]) throws IOException {
write(b, 0, b.length);
}
`