- * This method enables checking if a cached file has exceeded a certain
- * threshold(in days)
- *
- * @param file
- * the cached file
- * @param noOfDays
- * the threshold in days
- * @return
- */
- public static boolean isFileOlderThanThreshold(File file, int noOfDays)
- {
- Path filePath = file.toPath();
- BasicFileAttributes attr;
- int diffInDays = 0;
- try
- {
- attr = Files.readAttributes(filePath, BasicFileAttributes.class);
- diffInDays = (int) ((new Date().getTime()
- - attr.lastModifiedTime().toMillis())
- / (1000 * 60 * 60 * 24));
- // System.out.println("Diff in days : " + diffInDays);
- } catch (IOException e)
- {
- e.printStackTrace();
- }
- return noOfDays <= diffInDays;
- }
-
- /**