Java Delete File deleteFile(String filename)

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

Description

Deletes a file from the file system.

License

Open Source License

Parameter

Parameter Description
filename the pathname of the file to erase.

Return

true if and only if the file is successfully deleted; false otherwise.

Declaration

public static boolean deleteFile(String filename) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013-2015 UAH Space Research Group.
 * 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:/*from w ww  .jav a  2s  .  c  o  m*/
 *     MICOBS SRG Team - Initial API and implementation
 ******************************************************************************/

import java.io.File;

public class Main {
    /**
     * Deletes a file from the file system.
     * @param filename the pathname of the file to erase.
     * @return <code>true</code> if and only if the file is
     * successfully deleted; <code>false</code> otherwise.
     */
    public static boolean deleteFile(String filename) {

        File file2Delete = new File(filename);

        return file2Delete.delete();
    }
}

Related

  1. deleteFile(String filename)
  2. deleteFile(String filename)
  3. deletefile(String fileName)
  4. deleteFile(String FileName)
  5. deleteFile(String fileName)
  6. deleteFile(String fileName)
  7. deleteFile(String fileName)
  8. deleteFile(String fileName)
  9. deleteFile(String fileName)