FileUtil { public static String getExtension(String filename) { if (Util.isBlank(filename)) { return null; } if (filename.lastIndexOf('.') == -1) { return null; } return filename.substring(filename.lastIndexOf('.')+1); }  static String stripExtension(String filename); static String getExtension(String filename); static boolean hasExtension(String filename, String extension);  }
@Test public void testGetExtensionNull() { assertEquals(null, FileUtil.getExtension(null)); }
@Test public void testGetExtensionEmpty() { assertEquals(null, FileUtil.getExtension("")); }
@Test public void testGetExtensionBlank() { assertEquals(null, FileUtil.getExtension(" ")); }
@Test public void testGetExtensionNoExtension() { assertEquals(null, FileUtil.getExtension("some/file/without/an/extension")); }
@Test public void testGetExtensionWithExtension() { assertEquals("ext", FileUtil.getExtension("some/file/with/an/extension.ext")); }
@Test public void testGetExtensionWithMultiplePeriod() { assertEquals("ext2", FileUtil.getExtension("some/file/with/an/extension.ext1.ext2")); }