标签:上传文件 create last substr substring class except 文件名 java
public void upload(MultipartFile file, String saveurl,String showurl,) throws Exception { try { String suffix = file.getOriginalFilename().substring( //文件后缀 file.getOriginalFilename().lastIndexOf(".") + 1); File destFile = new File(saveurl); if (!destFile.exists()) { destFile.mkdirs(); } String fileNameNew = getFileNameNew() + "." + suffix;//新的文件名 File f = new File(destFile.getAbsoluteFile() + "/" + fileNameNew);//保存路径
f.createNewFile();
file.transferTo(f); // fileName = basePath + destDir + fileNameNew;
fileName = saveurl + fileNameNew;
oldfileName = file.getOriginalFilename();
newfileName = fileNameNew;
}
catch (Exception e) { throw e; }
}
标签:上传文件 create last substr substring class except 文件名 java
原文地址:http://www.cnblogs.com/syscn/p/7742011.html