Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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,
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. Algorithm:
1. Start 2. Create a class filedemo. Get the file name from the user. 3. Use the file functions and display the information about the file. 4. getName() displays the name of the file. 5. getPath() diplays the path name of the file. 6. getParent()-This method returns the pathname string of this abstract pathname's parent, or 7. null if this pathname does not name a parent directory. 8. exists() - Checks whether the file exists or not. 9. canRead()-This method is basically a check if the file can be read. 10. canWrite()-verifies whether the application can write to the file. 11. isDirectory() - displays whether it is a directory or not. 12. isFile() - displays whether it is a file or not. 13. lastmodified) - displays the last modified information. 14. length()- displays the size of the file. 15. delete() - deletes the file 16. Invoke the predefined functions to display the information about the file. 17. Stop
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started