This is due to the fact that yours dir, file1and file2point to the old path.
After completing these lines
File dir = new File("DIR");
dir.mkdir();
File file1 = new File(dir,"myfile1.txt");
file1.createNewFile();
File file2 = new File(dir,"myfile2.txt");
file2.createNewFile();
these will be the paths referenced by the variables,
dir = "DIR" // Exists
file1 = "DIR\myfile1.txt" //Exists
file2 = "DIR\myfile2.txt" //Exists
After doing
dir.renameTo(new File("myDIR"));
the paths referenced by the variables remain the same
dir = "DIR" // Doesn't exist anymore because it moved.
file1 = "DIR\myfile1.txt" // Doesn't exist anymore because it moved along with dir.
file2 = "DIR\myfile2.txt" // Doesn't exist anymore because it moved along with dir.
So when you call
System.out.print(file1.renameTo(new File(dir,"myf1.txt")));
You call renameTo()to a file that does not exist, and to a directory that also does not exist. Thus, it does not necessarily work.
.exists() dir, file1 file2, false.