Class DirectoryStreamUtils

java.lang.Object
com.nt.udc.util.DirectoryStreamUtils

public class DirectoryStreamUtils extends Object
  • Field Details

  • Constructor Details

    • DirectoryStreamUtils

      public DirectoryStreamUtils()
  • Method Details

    • getFileList

      public static List<File> getFileList(File dir, DirectoryStream.Filter<Path> filter) throws Exception
      Throws:
      Exception
    • getFileNameList

      public static List<String> getFileNameList(File dir, DirectoryStream.Filter<Path> filter) throws Exception
      Throws:
      Exception
    • getFileNameList

      public static List<String> getFileNameList(File dir) throws Exception
      Throws:
      Exception
    • getSortedListByBatchId

      public static String[] getSortedListByBatchId(File dir, DirectoryStream.Filter<Path> filter) throws Exception
      Given a directory name and a filename filter object, return a list of files within the directory which meet the filter requirements, sorted by the last modified date.
      Parameters:
      dir - File object identifying the directory containing the files.
      filter - FilenameFilter object used to select files which meet specific naming conditions.
      Returns:
      An array of file names, sorted oldest to newest by the last modified date.
      Throws:
      Exception
    • getSortedList

      public static String[] getSortedList(File dir, DirectoryStream.Filter<Path> filter) throws Exception
      Given a directory name and a filename filter object denoted by DirectoryStream.Filter, return a file name array of files within the directory which meet the filter requirements, sorted by the last modified date.
      Parameters:
      dir - File object identifying the directory containing the files.
      filter - DirectoryStream.Filter object used to select files which meet specific naming conditions.
      Returns:
      An array of file names, sorted oldest to newest by the the last modified date.
      Throws:
      Exception
    • getSortedList

      public static String[] getSortedList(File dir, FileComparator filecomp) throws Exception
      Given a directory name, return a list of files within the directory sorted by the given FileComparator criteria.
      Parameters:
      dir - File object identifying the directory containing the files.
      Returns:
      An array of file names, sorted oldest to newest by the FileComparator's criteria.
      Throws:
      Exception
    • getSortedList

      public static String[] getSortedList(File dir, DirectoryStream.Filter<Path> filter, FileComparator filecomp) throws Exception
      Given a directory name and a filename filter object denoted by DirectoryStream.Filter, return a file name array of files within the directory which meet the filter requirements, sorted by the given FileComparator criteria.
      Parameters:
      dir - File object identifying the directory containing the files.
      filter - DirectoryStream.Filter object used to select files which meet specific naming conditions.
      filecomp - FileComparator object used to sort files with criteria
      Returns:
      An array of file names, sorted oldest to newest by the FileComparator's criteria.
      Throws:
      Exception
    • getSortedListWithLimit

      public static String[] getSortedListWithLimit(File dir, DirectoryStream.Filter<Path> filter, int limit) throws Exception
      Retrieves a sorted list of file names from a specified directory, applying a given filter and limiting the number of results.
      Parameters:
      dir - The directory from which to retrieve files.
      filter - A DirectoryStream.Filter to filter the files.
      limit - The maximum number of file names to return. If limit is 0 or negative, all files are returned.
      Returns:
      A sorted array of file names from the directory, subject to the filter and limit.
      Throws:
      Exception - If an error occurs while accessing the directory or retrieving file names.
    • getSortedVector

      public static void getSortedVector(File dir, DirectoryStream.Filter<Path> filter, FileComparator filecomp, LinkedList fileNameVector) throws Exception
      Throws:
      Exception
    • getSortedVector

      public static void getSortedVector(File dir, DirectoryStream.Filter<Path> filter, FileComparator filecomp, LinkedList fileNameVector, int threadCount, int threadNum) throws Exception
      Throws:
      Exception
    • getSortedNormalizedVector

      public static void getSortedNormalizedVector(File dir, DirectoryStream.Filter<Path> filter, List<NormalizeFile> normalizedFiles)
      Given a directory named dir, a DirectoryStream.Filter named filter. It converts all the File from dir into NormalizeFile object which meets the filter requirements and add that into normalizedFiles List and then sort it.
      Parameters:
      dir - directory which needs to check
      filter - filter which is used to filter the files in dir.
      normalizedFiles - List of NormalizeFile
    • getSortedVector

      public static void getSortedVector(File dir, LinkedList fileNameVector, String glob, int numThreads, boolean orderReq) throws Exception
      Throws:
      Exception
    • getSortedVector

      public static void getSortedVector(File dir, DirectoryStream.Filter<Path> filter, FileComparator filecomp, LinkedList fileNameVector, boolean mtOrdered, int threadNum) throws Exception
      Throws:
      Exception
    • checkInput

      public static boolean checkInput(File dir, DirectoryStream.Filter<Path> filter)
      This method checks for an empty input directory.
      Returns:
      true, if directory contains files