Java File Exist fileExists(String file)

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

Description

TODO: candidate for common Tests whether a directory or file exists.

License

Open Source License

Parameter

Parameter Description
file The name of a directory or file.

Return

True if the file exists.

Declaration

public static boolean fileExists(String file) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2000, 2014 IBM Corporation and others.
 * 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
 * //from  w  w w .  j av  a 2s.c o  m
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

import java.io.File;

public class Main {
    /**
     * TODO: candidate for common
     * Tests whether a directory or file exists.
     * @param file The name of a directory or file.
     * @return True if the file exists.
     */
    public static boolean fileExists(String file) {
        File f = new File(file);
        return f.exists();
    }
}

Related

  1. fileExists(final String path)
  2. fileExists(final String path)
  3. fileExists(final String pathname)
  4. fileExists(String absolutePathAndFileName)
  5. fileExists(String aFilename)
  6. FileExists(String file)
  7. fileExists(String filename)
  8. fileExists(String filename)
  9. fileExists(String fileName)