public static boolean directoryExists(String dir){
  File tmp=new File(dir);
  return (tmp.isDirectory() && tmp.exists());
}

public static boolean directoryExists ( String dir ) { File tmp = new File ( dir ) ; return ( tmp . isDirectory ( ) && tmp . exists ( ) ) ; }
checks if the directory exists
