Check if directory exists in java



User Rating:  / 0
PoorBest 
Details
Category: Java
Created on Thursday, 15 November 2012 11:35
Last Updated on Thursday, 15 November 2012 11:35
Published on Thursday, 15 November 2012 11:35
Written by Administrator
Hits: 6425

Simple java code for check if directory exist :

View source
package com.developerpages.snippets.core;
 
import java.io.File;
 
public class CheckIfDirectoryExists {
    
    public static void main(String[] args) {
        File dir = new File("directory");
        boolean exists = dir.exists();
        System.out.println("Directory " + dir.getPath() + " exists: " + exists);
    }
}