我想在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();
}
它创建文件,但不写任何东西。我搜索了很多,但没有找到任何东西。我怎么了 我是否需要任何许可才能在HDFS中写入?
谢谢。
30秒到达战场
慕森卡
相关分类