Answers for "how to delete from text file java"

6

how to delete a file in java

File file = new File("filepath");
file.delete(); //Returns boolean
Posted by: Guest on November-21-2020
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 "how to delete from text file java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language