Question about File renameTo() method : Abnormal output
public static void main(String[] args) throws Exception
{
File fl1 = new File("D:/Education/Java/Test1");
File fl2 = new File("D:/Education/Java/Test2");
fl1.renameTo(fl2);
p("New File Name is : "+ fl1.getName());
}
For the above code snippet O/P is
run:
New File Name is : Test1
BUILD SUCCESSFUL (total time: 2 seconds)
My question is :
At my system although the Test1 gets renamed as Test2 after compilation but still fl1.getName() returns the old name Test1. Why so?