Kamal kannan Kamal kannan - 2 months ago 7
Groovy Question

How to delete My Local File

This My file Location /opt/dataFileUpload/temp/purchaseOrder/PO-8.pdf, I want to delete PO-8.pdf file.[Note: Only i want to delete The File Not the Folder Path]

Thanks in Advance,

Answer
        try{

        File file = new File("/opt/dataFileUpload/temp/purchaseOrder/PO-8.pdf");

        if(file.delete()){
            System.out.println(file.getName() + " is deleted!");
        }else{
            System.out.println("Delete operation is failed.");
        }

       }catch(Exception e){

        e.printStackTrace(); 

      }
Comments