Copy Code code 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 ())//See if the file exists
File NewFile = new file (Oldfile.getparent () +file.separator+newname.get (i) + ". mp4");
if (newfile.exists ()) {
System.out.println (i+ "already exist");/new file already exists
} else {
System.out.println (i+ "\ T" +oldfile.renameto (NewFile))//whether the old file was renamed successfully
}
}
}
}