日期:2014-05-16  浏览次数:20807 次

用apache common io包获得文件扩展名
apache common io包包含了很多非常实用的工具类,比如
连获得文件的扩展名都有了

import org.apache.commons.io.FilenameUtils; 
String extension = FilenameUtils.getExtension(fileName);  
              
if (extension.equals("zip") || extension.equals("bar")) {  
                ZipInputStream zip = new ZipInputStream(fileInputStream);  
                repositoryService.createDeployment().addZipInputStream(zip).deploy();