Java Delete File deleteFile(String fileName)

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

Description

delete File

License

Open Source License

Declaration

static public void deleteFile(String fileName) 

Method Source Code


//package com.java2s;
/*//from ww w .  j  a va  2 s .c o m
 * Copyright 2010
 * IBB-CEB - Institute for Biotechnology and Bioengineering - Centre of Biological Engineering
 * CCTC - Computer Science and Technology Center
 *
 * University of Minho 
 * 
 * This is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version. 
 * 
 * This code is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU Public License for more details. 
 * 
 * You should have received a copy of the GNU Public License 
 * along with this code. If not, see http://www.gnu.org/licenses/ 
 * 
 * Created inside the SysBioPseg Research Group (http://sysbio.di.uminho.pt)
 */

import java.io.File;

public class Main {
    static public void deleteFile(String fileName) {

        //System.out.println("FILE\t" + fileName);
        File f = new File(fileName);

        //          if (!f.exists())
        //            throw new IllegalArgumentException(
        //                "Delete: no such file or directory: " + fileName);
        //          if (!f.canWrite())
        //            throw new IllegalArgumentException("Delete: write protected: "
        //                + fileName);
        //
        //          if (f.isDirectory()) {
        //            String[] files = f.list();
        //            if (files.length > 0)
        //              throw new IllegalArgumentException(
        //                  "Delete: directory not empty: " + fileName);
        //          }

        if (f.exists())
            f.delete();

        //          if (!success)
        //            throw new IllegalArgumentException("Delete: deletion failed");
    }
}

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 name)