Fetch all files that match the file pattern <i>srcf</i> and display
their content on stdout.
@param srcf: a file pattern specifying source files
@exception: IOException
@see org.apache.hadoop.fs.FileSystem.globStatus
553493
void cat(String src, boolean verifyChecksum) throws IOException {
    //cat behavior in Linux
    //  [~/1207]$ ls ?.txt
    //  x.txt  z.txt
    //  [~/1207]$ cat x.txt y.txt z.txt
    //  xxx
    //  cat: y.txt: No such file or directory
    //  zzz

    Path srcPattern = new Path(src);
    new DelayedExceptionThrowing() {
      @Override
      void process(Path p, FileSystem srcFs) throws IOException {
        if (srcFs.getFileStatus(p).isDir()) {
          throw new IOException("Source must be a file.");
        }
        printToStdout(srcFs.open(p));
      }
    }.globAndProcess(srcPattern, getSrcFileSystem(srcPattern, verifyChecksum));
  }
1323505
protected FileStatus[] getFilteredFileStatuses(Path sourcePath, PathFilter pathFilter) throws IOException {
    return this.fs.listStatus(sourcePath, pathFilter);
  }
1093036
public int getNextFiles(final File[] files, final int batchSize) throws IOException {
		int c=0;
		while(c<batchSize) {
			File file=getNextFile();
			if(file==null) break;
			files[c++]=file;
		}
		return c;
	}
878661
private static void checkSrcPath(Configuration conf, List<Path> srcPaths
      ) throws IOException {
    List<IOException> rslt = new ArrayList<IOException>();
    List<Path> unglobbed = new LinkedList<Path>();
    for (Path p : srcPaths) {
      FileSystem fs = p.getFileSystem(conf);
      FileStatus[] inputs = fs.globStatus(p);

      if(inputs != null && inputs.length > 0) {
        for (FileStatus onePath: inputs) {
          unglobbed.add(onePath.getPath());
        }
      } else {
        rslt.add(new IOException("Input source " + p + " does not exist."));
      }
    }
    if (!rslt.isEmpty()) {
      throw new InvalidInputException(rslt);
    }
    srcPaths.clear();
    srcPaths.addAll(unglobbed);
  }
1072875
private FileStatus methodBasedGetFileInfo(String src) throws IOException {
    if (namenodeProtocolProxy.isMethodSupported(
        "getHdfsFileInfo", String.class)) {
      return HdfsFileStatus.toFileStatus(namenode.getHdfsFileInfo(src), src);
    } else {
      return namenode.getFileInfo(src);
    }
  }
522251
public List<String> getFileLinesAsList(File f) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(
            new DataInputStream(new FileInputStream(f))));
        List<String> result = new LinkedList<String>();
        String strLine;
        while ((strLine = br.readLine()) != null) {
            result.add(strLine);
        }
        br.close();
        return result;

    }
177441
protected boolean doesFileMatch(final File file, final CSNodeWrapper node) {
        if (!node.getNodeType().equals(CommonConstants.CS_NODE_FILE)) return false;

        // If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare
        if (file.getUniqueId() != null && file.getUniqueId().matches("^\\d.*")) {
            return file.getUniqueId().equals(Integer.toString(node.getId()));
        } else {
            // Since a content spec doesn't contain the database ids for the nodes use what is available to see if the files match
            return file.getId().equals(node.getEntityId());
        }
    }
1298403
private List<File> listFiles(File file, List<File> files) {
        File[] children = file.listFiles();
        
        if (children != null) {
            for (File child : children) {
                files.add(child);
                listFiles(child, files);
            }
        }
        
        return files;
    }
469040
def _readContaminantOutputFiles(self, directory, baseFileName, session, spatial, spatialReferenceID):
        
        if not os.path.isdir(directory):
            return
        if baseFileName == '':
            return

        # Look for channel output files denoted by the ".chan" after the base filename
        chanBaseFileName = '.'.join([baseFileName, 'chan'])

        # Get contents of directory
        directoryList = os.listdir(directory)

        # Compile a list of files with "basename.chan" in them
        chanFiles = []
        for thing in directoryList:
            if chanBaseFileName in thing:
                chanFiles.append(thing)

        # Assume all "chan" files are link node dataset files and try to read them
        for chanFile in chanFiles:
            linkNodeDatasetFile = LinkNodeDatasetFile()
            linkNodeDatasetFile.projectFile = self.projectFile

            try:
                linkNodeDatasetFile.read(directory=directory,
                                         filename=chanFile,
                                         session=session,
                                         spatial=spatial,
                                         spatialReferenceID=spatialReferenceID)
            except:
                log.warning('Attempted to read Contaminant Transport Output file {0}, but failed.'.format(chanFile))
1228495
public static List<FileStatus> listFilesRecursively(FileSystem fs, Path path, PathFilter fileFilter)
      throws IOException {
    return listFilesRecursively(fs, path, fileFilter, false);
  }
505818
private FileStatus versionBasedGetFileInfo(String src) throws IOException {
    if (namenodeVersion >= ClientProtocol.OPTIMIZE_FILE_STATUS_VERSION) {
      return HdfsFileStatus.toFileStatus(namenode.getHdfsFileInfo(src), src);
    } else {
      return namenode.getFileInfo(src);
    }
  }
763898
public static List<File> findAllFile(File file) {
        if (file == null || !file.exists()) {
            return Collections.emptyList();
        }

        if (file.isFile()) {
            return Collections.singletonList(file);
        }

        List<File> fileList = new ArrayList<>();
        File[] files = file.listFiles();
        for (File f : files) {
            fileList.addAll(findAllFile(f));
        }

        return fileList;
    }
738560
private S getInputStreamForFile(File file) throws IOException {
        assert file != null : "File must be specified";
        return this.getInputStreamForRawStream(new FileInputStream(file));
    }
203910
public static String readFile(File file) throws IOException {
        StringBuilder content = new StringBuilder();
        String line;
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            while ((line = reader.readLine()) != null) {
                content.append(line).append("\r\n");
            }
        }
        return content.toString();
    }
310600
private FileSystem getSrcFileSystem(Path src, boolean verifyChecksum
      ) throws IOException { 
    FileSystem srcFs = src.getFileSystem(getConf());
    srcFs.setVerifyChecksum(verifyChecksum);
    return srcFs;
  }
157770
public static File[] listFiles(final File target, final List<Pattern> patterns, final boolean include) {
        if (patterns == null || patterns.isEmpty())
            return target.listFiles();

        return target.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                for (Pattern pattern : patterns) {
                    Matcher matcher = pattern.matcher(name);
                    if (matcher.matches())
                        return include;
                }
                return !include;
            }

        });

    }
156104
public static List<String> listObjectsInFile(@NonNull File f){
        Preconditions.checkState(f.exists(), "File must exist: %s", f);

        List<String> out = new ArrayList<>();
        try (ZipFile zipFile = new ZipFile(f)){

            Enumeration<? extends ZipEntry> entries = zipFile.entries();
            while(entries.hasMoreElements()){
                ZipEntry e = entries.nextElement();
                String name = e.getName();
                if(!e.isDirectory() && name.startsWith("objects/")){
                    String s = name.substring(8);
                    out.add(s);
                }
            }
            return out;
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }