Here you can find the source of subFiles(String formatString, File[] files)
Parameter | Description |
---|---|
formatString | Format of the file name |
files | A list of files |
private static void subFiles(String formatString, File[] files)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; public class Main { private static final TreeMap<Date, File> backupList = new TreeMap<>(); /**//from w ww . j a v a 2 s .c o m * Gets a list of backups * * @param formatString Format of the file name * @param files A list of files */ private static void subFiles(String formatString, File[] files) { for (File file : files) { if (file.isDirectory()) { subFiles(formatString, file.listFiles()); // Calls same method again. } else { if (file.getName().endsWith(".zip")) { String dateString = file.getName(); DateFormat format = new SimpleDateFormat(formatString, Locale.ENGLISH); try { Date date = format.parse(dateString); backupList.put(date, file); } catch (Exception e) { e.printStackTrace(); } } } } } }