FileUtils { static String getExtension(String filename) { if (filename == null) { return null; } final int i = filename.lastIndexOf("."); return i < 0 ? "" : filename.substring(i + 1); }    }
@Test public void testGetExtension() { assertEquals("", FileUtils.getExtension("")); assertEquals("", FileUtils.getExtension("file")); assertEquals("", FileUtils.getExtension("file.")); assertEquals("png", FileUtils.getExtension("file.png")); assertEquals("jpg", FileUtils.getExtension("file.jpg")); }