我想在HDFS中创建一个文件并在其中写入数据.我用过这段代码:
Configuration config = new Configuration();
FileSystem fs = FileSystem.get(config);
Path filenamePath = new Path("input.txt");
try {
if (fs.exists(filenamePath)) {
fs.delete(filenamePath, true);
}
FSDataOutputStream fin = fs.create(filenamePath);
fin.writeUTF("hello");
fin.close();
}
Run Code Online (Sandbox Code Playgroud)
它会创建文件,但不会在其中写入任何内容.我搜索了很多但没有找到任何东西.我的问题是什么?我是否需要获得HDFS写入权限?
谢谢.