Java File Exist fileExists(String folderPath, String fileName)

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

Description

File exists.

License

Open Source License

Parameter

Parameter Description
folderPath the folder path
fileName the file name

Return

true, if successful

Declaration

private static boolean fileExists(String folderPath, String fileName) 

Method Source Code


//package com.java2s;

import java.io.File;

public class Main {
    /**// w ww . j av a  2  s.c om
     * File exists.
     *
     * @param folderPath the folder path
     * @param fileName the file name
     * @return true, if successful
     */
    private static boolean fileExists(String folderPath, String fileName) {
        File dir = new File(folderPath);
        File[] files = dir.listFiles();
        if (files != null) {
            for (File f : files) {
                if (f.getName().equals(fileName)) {
                    return true;
                }
            }
        }
        return false;
    }
}

Related

  1. FileExists(String filePath)
  2. fileExists(String filepath)
  3. fileExists(String filePath)
  4. fileExists(String filePathString)
  5. fileExists(String fName)
  6. fileExists(String name)
  7. fileExists(String parentDirectory, String filename)
  8. fileExists(String path)
  9. fileExists(String path)