public File rename(File file) {
String body="";
String ext="";
Date date = new Date();
int pot=file.getName().lastIndexOf(".");
if(pot!=-1){
body= date.getTime() +"";
ext=file.getName().substring(pot);
}else{
body=(new Date()).getTime()+"";
ext="";
}
String newName=body+ext;
file=new File(file.getParent(),newName);
return file;
}
java上传文件随机重命名
最新推荐文章于 2024-07-16 05:01:25 发布