package com.founder.hadoop;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.Path;
public class ListAllFile {
/**查看文件夹下所有文件路径
* @param args
* @author xw
*/
public static void main(String[] args) {
Configuration conf = new Configuration();
try {
FileSystem hdfs = FileSystem.get(conf);
Path path = new Path("/TestDir");
FileStatus[] status = hdfs.listStatus(path);
Path[] listedPath = FileUtil.stat2Paths(status);
System.out.println("===start===");
for(Path data : listedPath){
System.out.println(data);
}
System.out.println("===end===");
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.Path;
public class ListAllFile {
/**查看文件夹下所有文件路径
* @param args
* @author xw
*/
public static void main(String[] args) {
Configuration conf = new Configuration();
try {
FileSystem hdfs = FileSystem.get(conf);
Path path = new Path("/TestDir");
FileStatus[] status = hdfs.listStatus(path);
Path[] listedPath = FileUtil.stat2Paths(status);
System.out.println("===start===");
for(Path data : listedPath){
System.out.println(data);
}
System.out.println("===end===");
} catch (IOException e) {
e.printStackTrace();
}
}
}