EXP 8 PROGRAM FOR DISPLAYING FILE INFORMATION

 EX NO :8 

PROGRAM FOR DISPLAYING FILE INFORMATION 

AIM 

 To write a java program that reads a file name from the user, displays information about whether  the file exists, whether the file is readable, or writable, the type of file and the length of the file in bytes.  

PROCEDURE 

 1. Create a class filedemo. Get the file name from the user . 

 2. Use the file functions and display the information about the file. 

 3. getName() displays the name of the file. 

 4. getPath() diplays the path name of the file. 

 5. getParent() -This method returns the pathname string of this abstract pathname’s parent, or null  if this pathname does not name a parent directory. 

 6. exists() – Checks whether the file exists or not. 

 7. canRead()-This method is basically a check if the file can be read. 

 8. canWrite()-verifies whether the application can write to the file. 

 9. isDirectory() – displays whether it is a directory or not. 

 10. isFile() – displays whether it is a file or not. 

 11. lastmodified() – displays the last modified information. 

 12. length()- displays the size of the file. 

 13. delete() – deletes the file 

 14. Invoke the predefined functions and display the information about the file. 


Comments

Post a Comment

Popular posts from this blog

EXP 3 PROGRAM TO GENERATE PAYSLIP USING INHERITANCE

EXP 1 JAVA PROGRAM TO GENERATE ELECTRICITY BILL

EXP 2 PROGRAM TO IMPLEMENT CURRENCY CONVERTER, DISTANCE CONVERTER AND TIME CONVERTER USING PACKAGES