package pl.wroc.pwr.string; import java.io.File; import pl.wroc.pwr.IOperator; import pl.wroc.pwr.system.Consts; public class ExtractFileExtension implements IOperator { /** * */ private static final long serialVersionUID = -1500722797899186720L; private File file; public ExtractFileExtension( File file ) { this.file = file; } public void setFile( File file ) { this.file = file; } public String apply( ) { String name = this.file.getName( ); int index = name.lastIndexOf( Consts.DOT ); if ( index >= 0 ) { return name.substring( index + 1 ); } return Consts.EMPTY; } }