Android File Remove remove(String filePath)

Here you can find the source of remove(String filePath)

Description

remove

Declaration

public static void remove(String filePath) 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {
    public static void remove(String filePath) {
        try {// w  w  w .  j ava  2s .co  m
            File file = new File(filePath);
            remove(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void remove(File file) {
        if (file != null) {
            if (!file.isDirectory()) {
                file.delete();
            } else {
                String[] children = file.list();
                int size = children.length;
                for (int i = 0; i < size; i++) {
                    remove(new File(file, children[i]));
                }
                file.delete();
            }
        }
    }
}

Related

  1. remove(File file)
  2. deleteAllFiles(Vector filesToDelete)
  3. removeFile(String absPath)