派生自 projectDept/qhighschool

EricsHu
2022-12-05 068fc7f2e81178e55fa191a13709af64b1a163f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.qxueyou.scc.base.util;
 
import org.apache.commons.lang3.StringUtils;
 
/**
 * 文件工具类
 * @author xiadehu
 *
 */
public final class QFileUtils {  
 
    /**
     * 根据后缀名得到文件类型
     * @param fileName
     * @return
     */
    public static String getFileFormat(String fileName){
        
        if(StringUtils.isEmpty(fileName)) {
            return "DATA";
        }
        
        int lastDotIdx = fileName.lastIndexOf('.');
        return lastDotIdx<0?"DATA":fileName.substring(lastDotIdx+1).toUpperCase();
    }
      
}