如何在HDFS上写入缓冲图像 [英] How to write Buffered Image on HDFS
问题描述
在Map任务中,我尝试使用ImageIO.write(bufferedimage,"png",新File(outputFilenamepath));我收到异常,因为没有这样的文件或目录-FileNotFoundException.您能告诉我在存在缓冲图像的情况下如何在HDFS上写入图像文件
In Map task i am trying to use ImageIO.write(bufferedimage, "png", new File(outputFilenamepath)); i am getting exception as no such file or directory -FileNotFoundException. Could you please tell me as how to write image file on HDFS assuming buffered image is present
推荐答案
Mapper任务在Hadoop集群中的多个节点上同时运行.用普通的Java Writer类编写方法仅因为需要使用HDFS API写入数据而无法使用.
Mapper task run concurrently on multiple nodes in the Hadoop cluster. Your method of writing with normal Java Writer classes will not work just because you need to use HDFS API to write the data.
使用FileSystem API-
Use 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();
这篇关于如何在HDFS上写入缓冲图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!