File Input and Output
File Input and Output
Java Files
File handling is an important part of any
application.
To use the File class, create an object of the class, and specify the
filename or directory name:
Example:
Example:
In the following example, we use the Scanner class to read the contents
of the text file we created in the previous chapter:
Java Delete Files
Delete a File
To delete a file in Java, use the delete()
method:
Delete a Folder
You can also delete a folder. However, it must
be empty: