Here you can find the source of fileExists(String fileName)
Parameter | Description |
---|---|
fileName | the file name to check |
public static boolean fileExists(String fileName)
//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(); } }