java how to remove file code example
Example: java delete file
// java delete file
import java.io.File;
public class JavaDeleteFile
{
public static void main(String[] args)
{
try
{
File file = new File("E:\\example.txt");
if(file.delete())
{
System.out.println(file.getName() + " file deleted.");
}
else
{
System.out.println("failed");
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}