How to delete file in java code?
Here is the example of delete file operation
Here is the example of delete file operation
import java.io.File; public class FileDeleteExample { public static void main(String[] args) { try { File file = new File("D:\\db\\fileTest\\file1.txt"); if(file.delete()) { System.out.println(file.getName() + " is deleted successfully"); } else { System.out.println("Can not delete file"); } } catch(Exception e) { e.printStackTrace(); } } }
No comments:
Post a Comment