public static boolean exceedsSize(Configuration conf,Path path,long maxSize) throws IOException {
  long totalSize=0;
  FileSystem fs=FileSystem.get(path.toUri(),conf);
  Queue<Path> pathsToCheck=new LinkedList<>();
  pathsToCheck.add(path);
  while (pathsToCheck.size() > 0) {
    Path pathToCheck=pathsToCheck.remove();
    FileStatus[] statuses=fs.listStatus(pathToCheck);
    for (    FileStatus status : statuses) {
      if (status.isDirectory()) {
        pathsToCheck.add(status.getPath());
      }
 else {
        totalSize+=status.getLen();
        if (totalSize > maxSize) {
          return true;
        }
      }
    }
  }
  return false;
}

public static boolean exceedsSize ( Configuration conf , Path path , long maxSize ) throws IOException { long totalSize = 0 ; FileSystem fs = FileSystem . get ( path . toUri ( ) , conf ) ; Queue < Path > pathsToCheck = new LinkedList < > ( ) ; pathsToCheck . add ( path ) ; while ( pathsToCheck . size ( ) > 0 ) { Path pathToCheck = pathsToCheck . remove ( ) ; FileStatus [ ] statuses = fs . listStatus ( pathToCheck ) ; for ( FileStatus status : statuses ) { if ( status . isDirectory ( ) ) { pathsToCheck . add ( status . getPath ( ) ) ; } else { totalSize += status . getLen ( ) ; if ( totalSize > maxSize ) { return true ; } } } } return false ; }
check if a directory exceeds the specified size .
