Java Delete File deleteFile(Object fileObj)

Here you can find the source of deleteFile(Object fileObj)

Description

Deletes a file from the file system.

License

Open Source License

Parameter

Parameter Description
fileObj a parameter

Return

true if successful, otherwise false

Declaration

public static boolean deleteFile(Object fileObj) 

Method Source Code

//package com.java2s;
/* uDig - User Friendly Desktop Internet GIS client
 * http://udig.refractions.net/*w  ww . j  a v  a 2s .  com*/
 * (C) 2012, Refractions Research Inc.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD
 * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html).
 */

import java.io.File;

public class Main {
    /**
     * Deletes a file from the file system.
     * 
     * @param fileObj
     * @return true if successful, otherwise false
     */
    public static boolean deleteFile(Object fileObj) {
        if (fileObj instanceof File) {
            return deleteFile((File) fileObj);
        }
        return false;
    }

    /**
     * Deletes a file from the file system.
     * 
     * @param file
     * @return true if successful, otherwise false
     */
    public static boolean deleteFile(File file) {
        if (file != null) {
            if (file.exists()) {
                return file.delete();
            }
        }
        return false;
    }
}

Related

  1. deleteFile(final File file)
  2. deleteFile(final File file)
  3. deleteFile(final File file)
  4. deleteFile(final File file)
  5. deleteFile(final String dirname)
  6. deleteFile(String archiveFilename)
  7. deleteFile(String dest)
  8. deleteFile(String f)
  9. deleteFile(String file)