Android File Delete deleteFile(String filePath)

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

Description

delete File

License

Apache License

Declaration

public static void deleteFile(String filePath) 

Method Source Code

//License from project: Apache License 

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main{
    public static void deleteFile(String filePath) {
        if (StringUtil.isEmpty(filePath)) {
            return;
        }/*from  w  w  w . ja  va 2 s  .co  m*/

        File file = new File(filePath);
        if (!file.exists()) {
            return;
        }

        if (file.isDirectory()) {
            for (File tempFile : file.listFiles()) {
                deleteFile(tempFile.getPath());
            }
        }

        file.delete();
    }
}

Related

  1. deleteFile(File file)
  2. deleteFile(File file)
  3. deleteFile(File file)
  4. deleteFile(File root)
  5. deleteFile(File spec)
  6. deleteFile(String filePath)
  7. deleteFile(String filename)
  8. deleteFile(String path)
  9. deleteFile(String path)