Java File Delete delete(File file)

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

Description

Delete a file or folder including contained files or folders.

License

Apache License

Parameter

Parameter Description
file the file/folder to be deleted

Declaration

static void delete(File file) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    /**/*from w  w w . ja v  a2s  .co m*/
     * Delete a file or folder including contained files or folders.
     * 
     * @param file the file/folder to be deleted
     */
    static void delete(File file) {
        if (file.isFile()) {
            file.delete();
        } else if (file.isDirectory()) {
            File[] contained = file.listFiles();
            for (int f = 0; f < contained.length; f++) {
                delete(contained[f]);
            }
            file.delete();
        }
    }
}

Related

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