Delete a File in Java

Yes, you can simply delete a file directly from your computer.
But you also have the power to delete a file from within a Java program.

The File class has a delete() method.

Consider the following program:

deletecode

divider
Return to Unit Menu |  JavaBitsNotebook.com | MathBits.com | Terms of Use  | JavaMathBits.com

Notice: These materials are free for your on-line use at this site, but are not free for the taking.
Please do not copy these materials or re-post them to the Internet, as it is copyright infringement.
If you wish hard-copies of these materials, refer to our subscription area, JavaMathBits.com.
Help us keep these resources free. Thank you.