我在输入/ testingImagesInput中的hdfs中存储了大约100个图像,如下所示。
hduser@livingstream:/usr/local/hadoop$ bin/hadoop dfs -ls input
Warning: $HADOOP_HOME is deprecated.
Found 1 items
drwxr-xr-x - hduser supergroup 0 2014-06-03 12:07 /user/hduser/input/testingImagesInput
我正在尝试使用以下代码读取这些图像并将它们写入序列文件:
Configuration conf = new Configuration();
conf.set("fs.default.name","hdfs://localhost:54310");
FileSystem fs = FileSystem.get(conf);
FSDataInputStream in = null;
BytesWritable value = new BytesWritable();
Text key = new Text();
Path inpath = new Path(fs.getWorkingDirectory(),"input/testingImagesInput");
Path seq_path = new Path("seq_path");
设置路径和配置后,sequencefilewriter将在从inpath读取后写入seq_path
SequenceFile.Writer writer = null;
try {
System.out.println("reading from :"+inpath);
in = fs.open(inpath);
byte bufffer[] = new byte[in.available()];
in.read(bufffer);
writer = SequenceFile.createWriter(fs,conf,seq_path,key.getClass(),value.getClass());
writer.append(new Text(inpath.getName()), new BytesWritable(bufffer));
}catch (Exception e) {
TODO// handle e
}
然而,执行行
时in = fs.open(inpath);
它引发了以下错误:reading from :hdfs://localhost:54310/input/testingImagesInput // form sysout.
Exception MESSAGES = File does not exist: /input/testingImagesInput
我不确定发生了什么错误!任何人都可以指出我正确的方向。
更新
所以我给出了目录路径,即 hdfs:localhost:54310 / user / hduser / input / testingImagesInput 而没有指定图像的任何名称,当我添加了它能够的图像名称时读它。