/* 获得图片的保存路径 */
public static String generateURLforAnnotation(String path){
return AnnotationConstants.ABSOLUTE_URL + path + "/annotation";
}
File file = new File(URLUtils.generateURLforAnnotation(user.getUsername()));
//如果文件不存在就创建父目录
if (!file.exists())
file.mkdirs();
//先创建一个空文件,以图片名字命名放到父目录下面
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
String fileName = annotationPicFileName+"-"+dateFormat.format(date);
File copy = new File(file, fileName);
/* 删除原图片文件 */
String oldFileName = annotationService.getAnnotationImage(annotationId, user.getId());
File oldFile = new File(file, oldFileName);
oldFile.delete();
/* 复制图片文件,放到目录下 */
FileUtils.copyFile(this.getAnnotationPic(), copy);
ok!