Package com.nt.udc.util
Class DirectoryStreamUtils
java.lang.Object
com.nt.udc.util.DirectoryStreamUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Map
<String, ReentrantLock> static HashMap
<File, LinkedList> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkInput
(File dir, DirectoryStream.Filter<Path> filter) This method checks for an empty input directory.getFileList
(File dir, DirectoryStream.Filter<Path> filter) getFileNameList
(File dir) getFileNameList
(File dir, DirectoryStream.Filter<Path> filter) static String[]
getSortedList
(File dir, FileComparator filecomp) Given a directory name, return a list of files within the directory sorted by the given FileComparator criteria.static String[]
getSortedList
(File dir, DirectoryStream.Filter<Path> filter) 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.static String[]
getSortedList
(File dir, DirectoryStream.Filter<Path> filter, FileComparator filecomp) 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.static String[]
getSortedListByBatchId
(File dir, DirectoryStream.Filter<Path> filter) 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.static String[]
getSortedListWithLimit
(File dir, DirectoryStream.Filter<Path> filter, int limit) Retrieves a sorted list of file names from a specified directory, applying a given filter and limiting the number of results.static void
getSortedNormalizedVector
(File dir, DirectoryStream.Filter<Path> filter, List<NormalizeFile> normalizedFiles) Given a directory named dir, a DirectoryStream.Filternamed filter. static void
getSortedVector
(File dir, DirectoryStream.Filter<Path> filter, FileComparator filecomp, LinkedList fileNameVector) static void
getSortedVector
(File dir, DirectoryStream.Filter<Path> filter, FileComparator filecomp, LinkedList fileNameVector, boolean mtOrdered, int threadNum) static void
getSortedVector
(File dir, DirectoryStream.Filter<Path> filter, FileComparator filecomp, LinkedList fileNameVector, int threadCount, int threadNum) static void
getSortedVector
(File dir, LinkedList fileNameVector, String glob, int numThreads, boolean orderReq)
-
Field Details
-
hMap
-
dirLock
-
-
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
- 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
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
- ADirectoryStream.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.Filternamed 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 checkfilter
- 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
This method checks for an empty input directory.- Returns:
- true, if directory contains files
-