Software Development

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.

[wp_ad_camp_1]

Let’s say we have these files.

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

We can easily check the facts with these sample codes.

[wp_ad_camp_2]

This outputs

[wp_ad_camp_3]

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like