Copy codeThe Code is as follows: import java. io .*;
Import java. util .*;
Public class Test {
Public static void main (String [] args) throws IOException {
BufferedReader br = new BufferedReader (new FileReader ("output1.txt "));
List <String> newName = new ArrayList <String> ();
List <String> oldName = new ArrayList <String> ();
String line;
String [] col;
While (line = br. readLine ())! = Null ){
Col = line. split ("#");
NewName. add (col [0]);
OldName. add (col [1]);
}
Br. close ();
For (int I = 0; I <newName. size (); I ++ ){
File oldFile = new File ("D: \ TDDOWNLOAD \ heihei \" + oldName. get (I) + ". mp4 ");
System. out. println (oldFile. exists (); // check whether the file exists.
File newFile = new File (oldFile. getParent () + File. separator + newName. get (I) + ". mp4 ");
If (newFile. exists ()){
System. out. println (I + "already exists"); // the new file already exists.
} Else {
System. out. println (I + "\ t" + oldFile. renameTo (newFile); // whether the old file is successfully Renamed
}
}
}
}