Java Delete File deleteFile(File file)

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

Description

delete File

License

Open Source License

Declaration

public static boolean deleteFile(File file) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Yadu.// w  ww.ja  va  2s  .  com
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Yadu - initial API and implementation
 ******************************************************************************/

import java.io.File;

public class Main {
    public static boolean deleteFile(File file) {
        if (file == null)
            return false;
        return file.delete();
    }

    public static boolean deleteFile(String filePath) {
        if (isEmpty(filePath))
            return false;
        File file = new File(filePath);
        return deleteFile(file);
    }

    public static boolean isEmpty(String str) {
        if (str != null && !"".equals(str.trim()))
            return false;
        else
            return true;
    }
}

Related

  1. deleteFile(File file)
  2. deleteFile(File file)
  3. deleteFile(File file)
  4. deleteFile(File file)
  5. deleteFile(File file)
  6. deleteFile(File file)