Here you can find the source of fileExists(String folderPath, String fileName)
Parameter | Description |
---|---|
folderPath | the folder path |
fileName | the file name |
private static boolean fileExists(String folderPath, String fileName)
//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; } }