### Question:
StaticFileUtils { public static String getNewestFile(List<String> fileNames) { Collections.sort(fileNames, new Comparator<String>() { public int compare(String s1, String s2) { try { Date d1 = getDateFromFileName(s1); Date d2 = getDateFromFileName(s2); return d2.compareTo(d1); } catch (Exception e) { e.printStackTrace(); return 0; } } }); return fileNames.get(0); }  static synchronized String generateRandomBase(); static String expandUser(String pathIn); static DataOutputStream openDataOutputStreamFile(String fileName); static DataInputStream openDataInputStreamFile(String fileName); static DataOutputStream openDataOutputStreamFile(String fileName, int buffsize); static DataInputStream openDataInputStreamFile(String fileName, int buffsize); static byte[] readFile(File file); static byte[] readFile(String fileName); static void copyStreams(InputStream is, OutputStream os, PrintStream ps, long isSize, int buffsize); static void copyStreams(InputStream is, OutputStream os, PrintStream ps, int buffsize); static OutputStream openOutputFile(String fileName); static OutputStream openOutputFile(String fileName, int buffsize); static InputStream openInputFile(String fileName); static InputStream openInputFile(String fileName, int buffsize); static String getWorkingDirectory(); static List<String> joinPath(List<String> paths); static List<String> splitPathList(String pathName); static String[] splitPath(String pathName); static String joinPath(String firstPart, String secondPart); static String[] joinPath(String[] firstPart, String[] secondPart); static String splitPathToString(List<String> pathComps); static String splitPathToString(String[] splitPath); static String rebaseSplitPath(String srcBase, String srcPath, String dstBase); static String[] rebaseSplitPath(String[] srcBase, String[] srcPath, String[] dstBase); static String[] stripBeginingPath(String[] splitPath, int nTimes); static String directoryNameFromFullPath(String fullFilePath); static String stripDirectoryFromFileName(String fullFilePath); static String pathTail(String path); static String[] stripEndPath(String[] splitPath, int nTimes); static List<String> listDir(String filePath); static byte[] readInputStream(InputStream fis, int buffSize); static byte[] readInputStream(InputStream fis); static long computeCrc(InputStream fis); static void mkParentDir(String filePath); static Properties loadProperties(String propertiesPath); static String sanitizeDir(String dir); static Map<String, List> getLocalCachedFiles(String cacheLocation); static String getLogFileTime(String absoluteFileName); static void deleteLocalFile(String fileName); static void deleteFilesOlderThanNDays(String location, int nDays); static void delete(String location, long purgeTime); static Date getDateFromFileName(String fileName); static String getDateStringFromFileName(String fileName); static String getNewestFile(List<String> fileNames); static String getTotalTimeTaken(String dateStart); static Date getDate(String dateString, DateFormat format); static String getMonthYearFromFileDate(String dateString); static BufferedReader inputStreamToBufferedReader(InputStream is); static Random getRnd(); static boolean isSymLink(String filePath); static void close(Closeable stream); static BufferedReader inputStreamToBufferedReader(InputStream is, int buffSize); static String mergePathString(String... pathArray); static RandomAccessFile openRandomReadFile(String filePath); static long fileSize(String filePath); static void drainInputStream(InputStream is); static DateFormat filedf; static DateFormat jobdf; }### Answer:
@Test public void testGetNewestFile() throws Exception { String absoluteFileName1 = "/var/log/zxtm/rotated/2011021512-access_log.aggregated"; String absoluteFileName2 = "/var/log/zxtm/rotated/2011021513-access_log.aggregated"; String absoluteFileName3 = "/var/log/zxtm/rotated/2011021511-access_log.aggregated"; List<String> files = new ArrayList<String>(); files.add(absoluteFileName1); files.add(absoluteFileName2); files.add(absoluteFileName3); String newestFile = StaticFileUtils.getNewestFile(files); Assert.assertEquals(newestFile, absoluteFileName2); }