private void ls(AlluxioURI path, boolean recursive, boolean forceLoadMetadata, boolean dirAsFile,
                  boolean hSize, boolean pinnedOnly, String sortField, boolean reverse)
      throws AlluxioException, IOException {
    URIStatus pathStatus = mFileSystem.getStatus(path);
    if (dirAsFile) {
      if (pinnedOnly && !pathStatus.isPinned()) {
        return;
      }
      printLsString(pathStatus, hSize);
      return;
    }

    ListStatusPOptions.Builder optionsBuilder = ListStatusPOptions.newBuilder();
    if (forceLoadMetadata) {
      optionsBuilder.setLoadMetadataType(LoadMetadataPType.ALWAYS);
    }
    optionsBuilder.setRecursive(recursive);

    // If list status takes too long, print the message
    Timer timer = new Timer();
    if (pathStatus.isFolder()) {
      timer.schedule(new TimerTask() {
        @Override
        public void run() {
          System.out.printf("Getting directory status of %s files or sub-directories "
              + "may take a while.", pathStatus.getLength());
        }
      }, 10000);
    }
    List<URIStatus> statuses = mFileSystem.listStatus(path, optionsBuilder.build());
    timer.cancel();

    List<URIStatus> sorted = sortByFieldAndOrder(statuses, sortField, reverse);
    for (URIStatus status : sorted) {
      if (!pinnedOnly || status.isPinned()) {
        printLsString(status, hSize);
      }
    }
  }
private void ls ( AlluxioURI path , boolean recursive , boolean forceLoadMetadata , boolean dirAsFile , boolean hSize , boolean pinnedOnly , String sortField , boolean reverse ) throws AlluxioException , IOException { URIStatus pathStatus = mFileSystem . getStatus ( path ) ; if ( dirAsFile ) { if ( pinnedOnly && ! pathStatus . isPinned ( ) ) { return ; } printLsString ( pathStatus , hSize ) ; return ; } ListStatusPOptions . Builder optionsBuilder = ListStatusPOptions . newBuilder ( ) ; if ( forceLoadMetadata ) { optionsBuilder . setLoadMetadataType ( LoadMetadataPType . ALWAYS ) ; } optionsBuilder . setRecursive ( recursive ) ; Timer timer = new Timer ( ) ; if ( pathStatus . isFolder ( ) ) { timer . schedule ( new TimerTask ( ) { @ Override public void run ( ) { System . out . printf ( "Getting directory status of %s files or sub-directories " + "may take a while." , pathStatus . getLength ( ) ) ; } } , 10000 ) ; } List < URIStatus > statuses = mFileSystem . listStatus ( path , optionsBuilder . build ( ) ) ; timer . cancel ( ) ; List < URIStatus > sorted = sortByFieldAndOrder ( statuses , sortField , reverse ) ; for ( URIStatus status : sorted ) { if ( ! pinnedOnly || status . isPinned ( ) ) { printLsString ( status , hSize ) ; } } }
Displays information for all directories and files directly under the path specified in args.

@param path The {@link AlluxioURI} path as the input of the command
@param recursive Whether list the path recursively
@param dirAsFile list the directory status as a plain file
@param hSize print human-readable format sizes
@param sortField sort the result by this field