FileUtils { public static String getFilename( File file ) { if ( file == null ) { return null; } String path = splitFilename( file ).first; String parent = file.getParent(); return ( parent != null ) ? ( path.substring( file.getParent().length() + 1 ) ) : path; }  static String getFilename( File file ); static String getBasename( File file ); static String getFileExtension( File file ); static URL loadDeegreeConfiguration( Class<?> configurationClass, String fileName ); static List<File> findFilesForExtensions( File topDirectory, boolean recurse, String patternList ); static String getSystemCharset();  }
@Test public void testGetExclusiveExtension() { assertEquals( "foo", FileUtils.getFilename( new File( "/tmp/foo.txt" ) ) ); assertEquals( "foo.bar", FileUtils.getFilename( new File( "/tmp/foo.bar.txt" ) ) ); assertEquals( "foo.bar", FileUtils.getFilename( new File( "/tmp/foo.bar." ) ) ); assertEquals( "foo", FileUtils.getFilename( new File( "/tmp/foo" ) ) ); assertEquals( "foo", FileUtils.getFilename( new File( "/tmp.dir/foo" ) ) ); assertEquals( "", FileUtils.getFilename( new File( "" ) ) ); }