How to determine if a File or Directory exists in Java

If you want to know about a particular File or Directory physically exists in File System you can use exists method of File class

File file = new File("D:\\Java\\");

   // File or Directory exist
   // File or Directory does not exist



About author

User avatar

Waqas Anwar

Founder of, Senior Consultant, Microsoft .NET and Web Technologies