Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

hdfs get size of directory java

// import org.apache.hadoop.conf.Configuration;
// import org.apache.hadoop.fs.FileSystem;
// import org.apache.hadoop.fs.Path;

// Test for localhost
Configuration configuration = new Configuration();
configuration.set("fs.defaultFS", "hdfs://localhost:9000");
FileSystem fileSystem = FileSystem.get(configuration);
Path realPath = new Path(path);
System.out.println(fileSystem.getFileStatus(realPath).getLen());
 
PREVIOUS NEXT
Tagged: #hdfs #size #directory #java
ADD COMMENT
Topic
Name
3+5 =