how-to

File & Directory

How to check if directory exists

For working with directories, first add to your application java.io.* package:

import java.io.*;

For checking if dictionary exists, use function java.io.File.exists():

if ( new File( "c:\\temp" ).exists() ) System.out.print( "Directory exists" );

NOTE: You can use "c:\\temp\\" form too, the result will be same.