处理Filesystem closed事件
发布时间
阅读量:
阅读量
在应用HDFS的过程中
final Configuration conf = new Configuration();
final FileSystem fs = FileSystem.get(URI.create(hdfsFile), conf);
final Path path = new Path(hdfsFile);
if (fs.exists(path)) {
final FSDataInputStream is = fs.open(path);
final FileStatus stat = fs.getFileStatus(path);
final byte[] buffer = new byte[Integer.parseInt(String.valueOf(stat.getLen()))];
is.readFully(0, buffer);
is.close();
fs.close();
return buffer;
} else {
throw new Exception("the file is not found .");
}
全部评论 (0)
还没有任何评论哟~
