FileUtils { public static boolean hasExt(final String fileName, final String ext) { final String fullExt = ext.startsWith(dot) ? ext : dot + ext; return fileName.endsWith(fullExt); }  static String extFromFileName(final String filename); static boolean hasExtNoCase(final String fileName, final String ext); static boolean hasExt(final String fileName, final String ext); static String addExt(final String path, final String ext);  }
@Test public void testHasExt() { assertTrue(FileUtils.hasExt(name + ext, "ext")); assertFalse(FileUtils.hasExt(name + ext, "EXT")); assertTrue(FileUtils.hasExtNoCase(name + ext, "EXT")); assertTrue(FileUtils.hasExt(name + ext, ext)); assertFalse(FileUtils.hasExt(name + ext, ext.toUpperCase())); assertTrue(FileUtils.hasExtNoCase(name + ext, ext.toUpperCase())); assertFalse(FileUtils.hasExt(name + ext, schemaExt)); assertFalse(FileUtils.hasExt(name + ext, '.' + schemaExt)); }