/**
*
* 方法简介.保存到服务器
*
* @author HSG
* @date 创建时间 2019年3月21日
* @since V1.0
*/
public static void saveAttachFileToServer(CommonsMultipartFile attachFile,
String filepath, String filename) throws AppException {
FileOutputStream outputstream = null;
File file = null;
try {
file = new File(filepath + File.separator + filename);
file.createNewFile();
byte[] bytes = IOUtils.toByteArray(attachFile.getInputStream());
outputstream = new FileOutputStream(file);
outputstream.write(bytes);
outputstream.flush();
} catch (Exception e) {
Alert.FileError("文件写入异常,可能是文件损坏或不存在!错误信息为:" + e.getMessage());
} finally {
try {
if (outputstream != null) {
outputstream.close();
}
} catch (Exception e) {
Alert.FileError("文件写入异常,可能是文件损坏或不存在!错误信息为:" + e.getMessage());
}
}
}