上传文件,重命名

防止重名,需要重命名

public class FileRenameUtil {
public static StringBuffer fileRename(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String time = sdf.format(new Date());
StringBuffer buf = new StringBuffer(time);
Random r = new Random();
for(int x=0;x<3;x++){//循环取得三个不大于10的随机整数
buf.append(r.nextInt(10));
}
return buf;
}
}

猜你喜欢

转载自www.cnblogs.com/sanhao/p/9760716.html