Search for previous file in data format yyymmdd
Hi
I have a directory where log txt files are logged. Each log file has the following title date format 20180114.log, which is yyymmdd.
I want to search for data in the preceding file (date) so if the current date file is 20180114.log, I want to search the previous day 20180113.log, and then output the data i search for in anther text file.
How do I achieve this in java? any code examples I can follow?
I made a start by displaying the list of the files in the directory but could do with some help to achieve the above
Code:
public static void main(String[] args) {
File currentDir = new File("\\\\directory Path"); // current directory
displayDirectoryContents(currentDir);
}
public static void displayDirectoryContents(File dir) {
try {
File[] files = dir.listFiles();
for (File file : files) {
System.out.println(" file:" + file.getCanonicalPath());
}
} catch (IOException e) {
e.printStackTrace();
}
}
thanks in advance
Re: Search for previous file in data format yyymmdd
[When posting code, please use code tags so that the code is readable. Go Advanced, select the formatted code and click '#']
cheers!
Re: Search for previous file in data format yyymmdd