public static long getDirectorySize(Path path, FileSystem fs) throws IOException {
    ContentSummary cs = fs.getContentSummary(path);
    return cs.getLength();
  }
public static long getDirectorySize(Path path, FileSystem fs) throws IOException {
    ContentSummary cs = fs.getContentSummary(path);
    return cs.getLength();
  }
public static long getDirectorySize ( Path path , FileSystem fs ) throws IOException { ContentSummary cs = fs . getContentSummary ( path ) ; return cs . getLength ( ) ; }
Calculates the total size of all the contents of a directory,
including the contents of all of its subdirectories.
Does not include the size of directories themselves
(which are 0 in HDFS but may not be 0 on local file systems)

@param path path to recursively walk
@param fs FileSystem for this path
@return size of the directory's contents in bytes
@throws IOException
Calculates the total size of all the contents of a directory including the contents of all of its subdirectories . Does not include the size of directories themselves ( which are 0 in HDFS but may not be 0 on local file systems )