Code example for File

Methods: createNewFile, delete, exists

0
        if (!directory.isDirectory()) {
            if (!directory.mkdirs()) {
                return false; 
            } 
        } 
        File f = new File(directoryName, ".probe");
        try { 
            // Remove stale file if any 
            if (f.exists()) {
                f.delete();
            } 
            if (!f.createNewFile()) {
                return false; 
            } 
            f.delete();
            return true; 
        } catch (IOException ex) {
            return false; 
        } 
    }