java exists dir code example
Example: How to check if a directory exists in java
// How to check if a directory exists in java
import java.io.File;
public class CheckIfExists
{
public static void main(String[] args)
{
try
{
File fl = new File("B:/JavaExamples/CheckIfExists.txt");
fl.createNewFile();
System.out.println(fl.exists());
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}