在Map任务中我试图使用ImageIO.write(bufferedimage,“png”,new File(outputFilenamepath)); 我正在获得异常,因为没有这样的文件或目录-FileNotFoundException。 你能否告诉我如何在HDFS上写图像文件,假设存在缓冲图像
答案 0 :(得分:1)
Mapper任务在Hadoop集群中的多个节点上并发运行。使用普通Java Writer类编写的方法不会起作用,因为您需要使用HDFS API来编写数据。
使用FileSystem API -
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
Path inputfile = new Path("in/map");
FSDataOutputStream out = fs.create(inputfile);
if(value.toString()!= null){
out.writeBytes(value.toString());
}
out.close();