0

Java – Check for file or directory

The class java.io.File can be used to check for files or directory using the following methods:

  • isFile
  • isDirectorory

You may also be interested in exists() to check first if the file or directory exists.

Let’s say we have these files.

13-11-2016-11-37-01-pm

We can easily check the facts with these sample codes.

This outputs

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert