Java File Delete delete(File f)

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

Description

Recursively deletes a file or directory.

License

Apache License

Parameter

Parameter Description
f The file or directory to delete.

Return

true if file or directory was successfully deleted.

Declaration

public static boolean delete(File f) 

Method Source Code


//package com.java2s;
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *

import java.io.*;

public class Main {
    /**/* www  . j ava2  s  .co  m*/
     * Recursively deletes a file or directory.
     *
     * @param f The file or directory to delete.
     * @return <jk>true</jk> if file or directory was successfully deleted.
     */
    public static boolean delete(File f) {
        if (f == null)
            return true;
        if (f.isDirectory()) {
            File[] cf = f.listFiles();
            if (cf != null)
                for (File c : cf)
                    delete(c);
        }
        return f.delete();
    }
}

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, boolean recursive)