Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
What method do you use to delete a file in Java?
Think about what the purpose of the File class is.
What will happen if you try to delete a file that doesn't exist?
Remember the return value of delete() when the file isn't there.
What does the delete() method return if the file is successfully deleted?
Think about what indicates success.
True or False: The delete() method can delete directories.
Consider the implications of deleting something that has contents.
Create a Java program that deletes a file and handles potential exceptions gracefully. Include a user prompt to let them know if the file was found or not.
Start with a Scanner to get user input.
1 more question in this section. Enroll free to practise them all.
Enroll free