@Test public void isValidFileExtension() throws Exception { Assert.assertEquals(true, FileUtil.isValidFileExtension("log")); Assert.assertEquals(true, FileUtil.isValidFileExtension("log2")); Assert.assertEquals(true, FileUtil.isValidFileExtension("log_bak")); Assert.assertEquals(false, FileUtil.isValidFileExtension(".log")); Assert.assertEquals(false, FileUtil.isValidFileExtension("$log")); Assert.assertEquals(false, FileUtil.isValidFileExtension(" log")); }
public static boolean isValidFileExtension(String extension) { for (int i = 0; i < extension.length(); i++) { char c = extension.charAt(i); if (!(Character.isDigit(c) || Character.isLetter(c) || c == '_')) { return false; } } return true; }
FileUtil { public static boolean isValidFileExtension(String extension) { for (int i = 0; i < extension.length(); i++) { char c = extension.charAt(i); if (!(Character.isDigit(c) || Character.isLetter(c) || c == '_')) { return false; } } return true; } }
FileUtil { public static boolean isValidFileExtension(String extension) { for (int i = 0; i < extension.length(); i++) { char c = extension.charAt(i); if (!(Character.isDigit(c) || Character.isLetter(c) || c == '_')) { return false; } } return true; } private  FileUtil(); }
FileUtil { public static boolean isValidFileExtension(String extension) { for (int i = 0; i < extension.length(); i++) { char c = extension.charAt(i); if (!(Character.isDigit(c) || Character.isLetter(c) || c == '_')) { return false; } } return true; } 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 boolean isValidFileExtension(String extension) { for (int i = 0; i < extension.length(); i++) { char c = extension.charAt(i); if (!(Character.isDigit(c) || Character.isLetter(c) || c == '_')) { return false; } } return true; } 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);  }