Java Delete File deleteFile(File file)

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

Description

delete File

License

Open Source License

Declaration

public static void deleteFile(File file) throws IOException 

Method Source Code


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

import java.io.File;

import java.io.IOException;

public class Main {
    public static void deleteFile(File file) throws IOException {
        if (file != null) {
            for (File childFile : file.listFiles()) {
                if (childFile.isDirectory()) {
                    deleteFile(childFile);
                } else {
                    if (!childFile.delete()) {
                        throw new IOException();
                    }// ww w. ja v  a2  s  . c  o  m
                }
            }
            if (!file.delete()) {
                throw new IOException();
            }
        }
    }
}

Related

  1. deleteFile(File file)
  2. deleteFile(File file)
  3. deleteFile(File file)
  4. deleteFile(File file)
  5. deleteFile(File file)