Last active
          February 7, 2018 14:37 
        
      - 
      
- 
        Save zubayerahamed/14eaa7f58ac621621050fe1610f40f52 to your computer and use it in GitHub Desktop. 
    How to delete a file in java
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import java.io.File; | |
| public class DeleteFile | |
| { | |
| public static void main(String[] args) | |
| { | |
| try{ | |
| File file = new File("c:\\logfile20100131.log"); | |
| if(file.delete()){ | |
| System.out.println(file.getName() + " is deleted!"); | |
| }else{ | |
| System.out.println("Delete operation is failed."); | |
| } | |
| }catch(Exception e){ | |
| e.printStackTrace(); | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment