Answers for "removing a file java"

3

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();  
      }
   }
}
Posted by: Guest on February-18-2021

Code answers related to "removing a file java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language