Java File Delete delete(File f)

Here you can find the source of delete(File f)

Description

delete

License

Open Source License

Declaration

public static void delete(File f) throws Exception 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static void delete(File f) throws Exception {
        try {//  ww  w.j ava  2s.c o  m
            if (f.exists()) {
                if (f.isDirectory()) {
                    File[] child = f.listFiles();
                    for (File fc : child) {
                        delete(fc);
                    }
                }
                f.delete();
            }
            f.deleteOnExit();
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * delete file
     * 
     * @param file
     * @throws Exception
     */
    public static void delete(String file) throws Exception {
        try {
            File f = new File(file);
            delete(f);
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
}

Related

  1. delete(File f)
  2. delete(File f)
  3. delete(File f)
  4. delete(File f)
  5. delete(File f)
  6. delete(File f)
  7. delete(File f)
  8. delete(File f)
  9. delete(File f)