How to delete a directory when the virtual machine terminates in Java

1 Answer

0 votes
package javaapplication1;

import java.io.File;
import java.io.IOException;

public class JavaApplication1 {

    public static void main(String[] args) throws IOException {

        try {
            
            File file = new File("d://tmp");

            file.deleteOnExit();
            
        } catch (Exception e) {
            System.out.print(e);
        }
    }
}


/*
        
run:
  

    
 */

 



answered Nov 16, 2016 by avibootz

Related questions

1 answer 152 views
1 answer 200 views
1 answer 77 views
2 answers 170 views
1 answer 171 views
1 answer 229 views
...