FilenameUtils { public static String stripExtension(final String filename) { if (null == filename) { return null; } final int index = filename.lastIndexOf(EXTENSION_SEPARATOR); return (index < 0) ? filename : filename.substring(0, index); }  static String getExtension(final String filename); static String getExtension(final String filename, final boolean isGreedy); static String stripExtension(final String filename); static String makeFilename(final String name, final String ext);  }
@Test public void testStripExtension() { final Object[][] testParameters = new Object[][] {{"HelloWorld.png", "HelloWorld"}, {"Hello.World.jpg", "Hello.World"}}; assertNull(FilenameUtils.stripExtension(null)); for (final Object[] testParameter : testParameters) { String expected = (String) testParameter[1]; String filename = (String) testParameter[0]; assertEquals(expected, FilenameUtils.stripExtension(filename)); } }