package com.saye.hrs.commons.file;

import java.io.File;

public class FileDUtil {

	/**
	 * 得到文件的扩展名:大写字母的自动转换为小写字母
	 * @param f
	 * @return
	 */
    public static String getExtension(File f) { 
        return (f != null) ? getExtension(f.getName()) : ""; 
    } 

    public static String getExtension(String filename) { 
        return getExtension(filename,""); 
    }

    public static String getExtension(String filename, String defExt) { 
        if ((filename != null) && (filename.length() > 0)) { 
            int i = filename.lastIndexOf('.'); 

            if ((i >-1) && (i < (filename.length() - 1))) { 
                return filename.substring(i + 1).trim().toLowerCase(); 
            } 
        } 
        return defExt; 
    }
    
    public static void main(String[] args) {
		
    	File f = new File("d:\test.XLSX");
    	System.out.println(getExtension(f));
	}
}
