public static String getExtension ( String fileName ) { if ( fileName == null ) { return null ; } else { int number = fileName . lastIndexOf ( ' ' ) ; if ( number >= 0 ) { return fileName . substring ( number + 1 , fileName . length ( ) ) ; } else { return null ; } } }
If the file is like name . extension This function returns extension for filename = name . this returns for filemane = name this retuns null ; for filemane = . extension this retuns extension ; for filemane = . this retuns ;