code: public static FileStatus[] listStatus(FileSystem fs, Path f, int depth)
        throws IOException {
      if (null == f) {
        throw new IllegalArgumentException("Path cannot be null.");
      }
      if (null == fs) {
        throw new IllegalArgumentException("File system cannot be null.");
      }
      if (depth < 0) {
        throw new IllegalArgumentException("Depth cannot be negative.");
      }
  
      if (depth == 0) {
        FileStatus[] fileStatus = {fs.getFileStatus(f)};
        return fileStatus;
      }
  
      List<FileStatus> fileStatuses = listStatusHelper(fs, f, depth,
          new ArrayList<FileStatus>());
      return fileStatuses.toArray(new FileStatus[fileStatuses.size()]);
    }
docs: Return an array of FileStatus objects for each file beneath
  the given path to a specified depth (inclusive). Directories at
  the given depth will be returned, while directories above that
  depth will not.
  @param fs FileSystem on which to operate
  @param f starting path
  @param depth the depth of recursion. If 0 the function will
  return the status of the current file or directory.
  @exception IOException If this operation fails