Here you can find the source of getClassPath(String packageName, String name)
public static File getClassPath(String packageName, String name)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; public class Main { private static final String ENCODING = "UTF-8"; public static File getClassPath(String packageName, String name) { String path = Thread.currentThread().getContextClassLoader().getResource("").getPath(); try {/*from w w w .j av a2 s. c o m*/ path = URLDecoder.decode(path, ENCODING); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } File file = new File(path + getFilePath(packageName, name)); return file; } private static String getFilePath(String packageName, String name) { String path = packageName.replaceAll("\\.", "/"); return path + "/" + name;//"/" + } }