Java Reference
In-Depth Information
catch(IOException e){
e.printStackTrace();
}
}
public static void printFileDetails(File f) {
System.out.println("Absolute Path: " + f.getAbsoluteFile());
System.out.println("File exists: " + f.exists());
System.out.println("------------------------------");
}
}
Before creating the new file:
Absolute Path: C:\javabook\my_new_file.txt
File exists: false
------------------------------
After creating the new file:
Absolute Path: C:\javabook\my_new_file.txt
File exists: true
------------------------------
After deleting the new file:
Absolute Path: C:\javabook\my_new_file.txt
File exists: false
------------------------------
After recreating the new file:
Absolute Path: C:\javabook\my_new_file.txt
File exists: true
------------------------------
After using deleteOnExit() method:
Absolute Path: C:\javabook\my_new_file.txt
File exists: true
------------------------------
Before renaming file:
Absolute Path: C:\javabook\my_first_file.txt
File exists: true
------------------------------
Absolute Path: C:\javabook\my_second_file.txt
File exists: false
------------------------------
After renaming file:
Absolute Path: C:\javabook\my_first_file.txt
File exists: false
------------------------------
Absolute Path: C:\javabook\my_second_file.txt
File exists: true
------------------------------
Search WWH ::




Custom Search