@Test public void parseFileExtension() throws Exception { String ext0 = FileUtil.parseFileExtension("app.208-05-01.log"); Assert.assertEquals("log", ext0); ext0 = FileUtil.parseFileExtension("app.208-05-01.log.gz"); Assert.assertEquals("gz", ext0); ext0 = FileUtil.parseFileExtension("app.log.gz"); Assert.assertEquals("gz", ext0); ext0 = FileUtil.parseFileExtension("app"); Assert.assertEquals(null, ext0); ext0 = FileUtil.parseFileExtension("app."); Assert.assertEquals(null, ext0); ext0 = FileUtil.parseFileExtension("."); Assert.assertEquals(null, ext0); ext0 = FileUtil.parseFileExtension(""); Assert.assertEquals(null, ext0); ext0 = FileUtil.parseFileExtension(null); Assert.assertEquals(null, ext0); }
public static String parseFileExtension(String filename) { if (filename == null) { return null; } int pos = filename.lastIndexOf('.'); if (pos < 0 || (pos+1) >= filename.length()) { return null; } return filename.substring(pos+1); }
FileUtil { public static String parseFileExtension(String filename) { if (filename == null) { return null; } int pos = filename.lastIndexOf('.'); if (pos < 0 || (pos+1) >= filename.length()) { return null; } return filename.substring(pos+1); } }
FileUtil { public static String parseFileExtension(String filename) { if (filename == null) { return null; } int pos = filename.lastIndexOf('.'); if (pos < 0 || (pos+1) >= filename.length()) { return null; } return filename.substring(pos+1); } private  FileUtil(); }
FileUtil { public static String parseFileExtension(String filename) { if (filename == null) { return null; } int pos = filename.lastIndexOf('.'); if (pos < 0 || (pos+1) >= filename.length()) { return null; } return filename.substring(pos+1); } private  FileUtil(); static boolean equals(File file1, File file2); static boolean isValidFileExtension(String extension); static String parseFileExtension(String filename); static File[] findFiles(File dir, FileFilter filter); static void copy(File sourceFile, File targetFile); static boolean copy(File sourceFile, File targetFile, boolean overwrite); }
FileUtil { public static String parseFileExtension(String filename) { if (filename == null) { return null; } int pos = filename.lastIndexOf('.'); if (pos < 0 || (pos+1) >= filename.length()) { return null; } return filename.substring(pos+1); } private  FileUtil(); static boolean equals(File file1, File file2); static boolean isValidFileExtension(String extension); static String parseFileExtension(String filename); static File[] findFiles(File dir, FileFilter filter); static void copy(File sourceFile, File targetFile); static boolean copy(File sourceFile, File targetFile, boolean overwrite);  }