Java Delete File deleteFile(String file)

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

Description

Delete a file

License

Apache License

Parameter

Parameter Description
file a parameter

Declaration

public static boolean deleteFile(String file) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {
    /**//w w w .ja va2 s .c om
     * Delete a file
     *
     * @param file
     * @return
     */
    public static boolean deleteFile(String file) {
        File f = new File(file);
        if (f.exists() && f.isFile()) {
            return f.delete();
        }
        return true;
    }

    /**
     * Check if it is a valid file
     *
     * @param file
     * @return
     */
    public static boolean isFile(String file) {
        File f = new File(file);
        return f.exists() && f.isFile();
    }
}

Related

  1. deleteFile(String dest)
  2. deleteFile(String f)
  3. deleteFile(String file)
  4. deleteFile(String file)
  5. deleteFile(String file)
  6. deleteFile(String filename)
  7. deleteFile(String fileName)
  8. deleteFile(String fileName)
  9. deleteFile(String fileName)