In this section, you will learn how to check the existence of the particular file.
In this section, you will learn how to check the existence of the particular file.In this section, you will learn how to check the existence of the particular file.
Description of code:
This is a very simple task. Here we have to check whether the specified file or directory exists or not. For this, we have created an object of class File and used exists() method. This method checks the existence of the file and returns true if the files exists otherwise returns false.
exists(): It checks whether the file or directory denoted by the pathname exists or not.
Here is the code:
import java.io.*;
|
In the above code, method exists() is used. This method checks whether the file exists or not.
Output
File or Directory does not exists. |