st), conf);
fs.deleteOnExit(new Path(dst));
fs.close();
}
/**遍历HDFS上的文件和目录*/
private static void getDirectoryFromHdfs() throws FileNotFoundException,IOException {
String dst = "hdfs://192.168.0.113:9000/user/zhangzk";
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(dst), conf);
FileStatus fileList[] = fs.listStatus(new Path(dst));
int size = fileList.length;
for(int i = 0; i < size; i++){
System.out.println("name:" + fileList[i].getPath().getName() + "\t\tsize:" + fileList[i].getLen());
}
fs.close();
}
}
注意:对于append操作,从hadoop-0.21版本开始就不支持了