Class FileContentsDelegate

java.lang.Object
com.redhat.parodos.patterndetection.clue.delegate.FileContentsDelegate

public class FileContentsDelegate extends Object
Helper methods for working with Files and their contents.
Author:
Luke Shannon (Github: lshannon)
  • Constructor Details

    • FileContentsDelegate

      public FileContentsDelegate()
  • Method Details

    • getFilePaths

      public List<String> getFilePaths(String basePath) throws IOException
      Provides a list of Files in a base directory
      Parameters:
      basePath -
      Returns:
      list of Strings containing the full path of all the files in the base directory
      Throws:
      IOException
    • getFolderPaths

      public List<String> getFolderPaths(String basePath)
      Provides a list of Folders (and Sub Folders) under a base directory
      Parameters:
      basePath -
      Returns:
      List of String values, each value containing the full path of a folder or sub-folder found under the base directory
      Throws:
      IOException
    • getPaths

      public void getPaths(File dir, String base, List<String> paths)
      A recursive method that updates the passed in List of strings to contains the paths of each file/folder found under the directory
      Parameters:
      dir - Current location in the scan (can be a file or folder). If its a folder it triggers a recursive call
      base - the location from which the scan started
      paths - the list of file system locations as a String that is being recursively brought up
    • fileContentsToList

      public List<String> fileContentsToList(File currentFile) throws IOException
      Gets the contents of a file as List of Strings
      Parameters:
      currentFile -
      Returns:
      List of Strings with the contents of the file
      Throws:
      IOException