Java File Exist fileExists(String fileName)

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

Description

Checks to see if the given file exists.

License

Open Source License

Parameter

Parameter Description
fileName the file name to check

Return

true if it exists; false if it does not or is a directory rather than a file

Declaration

public static boolean fileExists(String fileName) 

Method Source Code


//package com.java2s;
/*// www. j a  va2 s . com
 * Copyright 2008, Myron Marston <myron DOT marston AT gmail DOT com>
 * 
 * This file is part of Fractal Composer.
 * 
 * Fractal Composer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * at your option any later version.
 * 
 * Fractal Composer 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Fractal Composer.  If not, see <http://www.gnu.org/licenses/>. 
 */

import java.io.*;

public class Main {
    /**
     * Checks to see if the given file exists.
     * 
     * @param fileName the file name to check
     * @return true if it exists; false if it does not or is a directory rather 
     *         than a file
     */
    public static boolean fileExists(String fileName) {
        File testFile = new File(fileName);
        return testFile.exists() && testFile.isFile();
    }
}

Related

  1. fileExists(String filename)
  2. fileExists(String filename)
  3. fileExists(String filename)
  4. FileExists(String filename)
  5. fileExists(String fileName)
  6. fileExists(String filepath)
  7. fileExists(String filePath)
  8. FileExists(String filePath)
  9. fileExists(String filePathString)