Import java. Io .*;
Import java. util .*;
Class testfile {
Public static void main (string [] ARGs ){
File TF = new file ("testfile.txt ");
If (Tf. exists ())
{
TF. Delete ();
System. Out. println ("deleted ");
}
Else
{
Try {
TF. createnewfile ();
} Catch (exception W)
{
W. printstacktrace ();
}
}
System. Out. println ("file name:" +
TF. getname ());
System. Out. println ("parent :"
+ TF. getparent ());
System. Out. println ("Relative Path:" +
TF. getpath ());
System. Out. println ("absolutefile:" +
TF. getabsolutefile ());
System. Out. println ("absolutepath:" +
TF. getabsolutepath ());
System. Out. println ("whether it is a directory:" +
TF. isdirectory ());
System. Out. println ("hash value:" +
TF. hashcode ());
System. Out. println (Tf. exists ()? "Exists": "Not
Found ");
System. Out. println (Tf. ishidden ()? "Hide": "Not
Hide ");
System. Out. println ("created at:" + new
Date (Tf. lastmodified ()));
//
Use File to check whether a file exists. If no file exists, it is created and deleted.
}
}