Java Utililty Methods Delete File

List of utility methods to do Delete File

Description

The list of methods to do Delete File are organized into topic(s).

Method

voiddeleteFile(String fileName)
delete File
File f = new File(fileName);
if (!f.exists())
    throw new IllegalArgumentException("Delete: no such file or directory: " + fileName);
if (!f.canWrite())
    throw new IllegalArgumentException("Delete: write protected: " + fileName);
if (f.isDirectory()) {
    String[] files = f.list();
    if (files.length > 0)
...
voiddeleteFile(String fileName)
delete File
File f = new File(fileName);
if (f.exists())
    f.delete();
booleandeleteFile(String filename)
Delete a file
System.out.println("Deleting " + filename);
try {
    File outtree = new File(filename);
    if (outtree.exists())
        outtree.delete();
} catch (Exception e) {
    return false;
return true;
booleandeleteFile(String fileName)
This deletes the specified file.
File file = new File(fileName);
return file.delete();
voiddeleteFile(String filename)
delete File
if (filename == null) {
    return;
filename = getJavaFileSystemPath(filename);
java.io.File file = new java.io.File(filename);
if (file.exists() && file.isFile()) {
    boolean isOK = file.delete();
    if (!isOK) {
...
voiddeleteFile(String name)
delete File
String diskPath = System.getProperty("java.io.tmpdir");
final File diskDir = new File(diskPath);
File dataFile = new File(diskDir, name + ".data");
if (dataFile.exists()) {
    dataFile.delete();
File indexFile = new File(diskDir, name + ".index");
if (indexFile.exists()) {
...
voiddeleteFile(String name)
delete File
deleteFile(new File(name));