Here you can find the source of createDir(String pathName)
public static File createDir(String pathName) throws Exception
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; import java.net.URL; public class Main { public static File createDir(String pathName) throws Exception { File dir = new File(getClasspathRootDir() + pathName); if (!dir.exists()) dir.mkdir();/*from w w w . j a va2 s.c o m*/ return dir; } public static String getClasspathRootDir() throws Exception { File tmpRoot = getClassPathFile("test.properties").getParentFile(); return tmpRoot.getCanonicalPath().replaceAll("%20", " "); } public static File getClassPathFile(String pathName) throws Exception { // In windows, pathnames with spaces are returned as %20 if (pathName.indexOf("%20") != -1) pathName = pathName.replaceAll("%20", " "); File tmp = new File(getResourceURL(pathName).getFile()); return tmp; } public static URL getResourceURL(String resource) throws IOException { URL url = null; ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader != null) url = loader.getResource(resource); if (url == null) url = ClassLoader.getSystemResource(resource); if (url == null) throw new IOException("Resource " + resource + " was not found"); return url; } }