How to check if a File exists within a Directory in Java


This article demonstrates how to check if a file exists in a directory in Java.

Software Environment

  • Windows 7 Professional SP1
  • Eclipse – Kepler Release
  • Java 1.7 (1.7.0_67 – Windows x86)
  • Apache Commons IO 2.4

First Things, First!

Download Apache Common IO from http://commons.apache.org/proper/commons-io/. The library has no dependencies. If you are using an IDE, reference the .jar file.

Use It

Get the Codes