Here you can find the source of fileExists(String filename)
Parameter | Description |
---|---|
filename | The path to the file whose existence will be checked. |
Parameter | Description |
---|---|
FileNotFoundException | if the file does not exist. |
public static void fileExists(String filename) throws FileNotFoundException
//package com.java2s; import java.io.*; public class Main { /**/* ww w .j a v a 2 s . c o m*/ * This checks to see if a file exists for the given path and throws * a FileNotFoundException if the file does not exist. * * @param filename The path to the file whose existence will be checked. * * @throws FileNotFoundException if the file does not exist. */ public static void fileExists(String filename) throws FileNotFoundException { File file = new File(filename); if (!file.exists()) { throw new FileNotFoundException("File [" + filename + "] does not exist."); } } }