public void fileRename(String tmpFilePath){
String[] fileType = fileName2.split("\.");
File file = new File(tmpFilePath+"\"+fileName2);
if (file.exists()){
String newFileName = fileType[0]+"-"+id2+"."+fileType[fileType.length-1];
file.renameTo(new File(tmpFilePath+"\"+newFileName));
href = href+id2+"/media";
HttpPostWithJson(href, JSON.toJSONString("http://192.168.6.174:8889/ProjectFiles/UploadFile/"+newFileName));
File file1 = new File("D:\IdeaProjects\toolupload\log\confFile\"+fileName2+".conf");
file1.delete();
}
}
关键为renameTo方法