java get size of directory in hadoop fs

htt‮‬ps://www.lautturi.com
java get size of directory in hadoop fs
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.conf.Configuration;

...

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());
Created Time:2017-09-07 23:27:53  Author:lautturi