FileName { public String getSuffix() { int suffixPos = fileName.lastIndexOf('.'); if (suffixPos < 0) { suffixPos = fileName.length() - 1; } return fileName.substring(suffixPos + 1); } FileName(String fileName); String getSuffix(); boolean endsWith(String suffix); FileName appendSuffix(String suffix); FileName stripSuffix(); FileName replaceSuffix(String newSuffix); @Override String toString();  }
@Test public void testGetSuffix() { FileName fn = new FileName("test.suf"); assertEquals("suf", fn.getSuffix()); fn = new FileName("test"); assertEquals("", fn.getSuffix()); fn = new FileName("my.test.file.suf"); assertEquals("suf", fn.getSuffix()); fn = new FileName(""); assertEquals("", fn.getSuffix()); fn = new FileName(".suf"); assertEquals("suf", fn.getSuffix()); }