Here you can find the source of checkDirectory(String dir)
private static boolean checkDirectory(String dir)
//package com.java2s; import java.io.File; public class Main { private static boolean checkDirectory(String dir) { File dirObj = new File(dir); if (dirObj.exists()) { if (!dirObj.isDirectory()) { dirObj.delete();//from ww w . ja v a 2s . co m } return false; } if (!dirObj.exists()) { dirObj.mkdirs(); } return true; } }