获取课程目录
//时代Java - nowjava.com //package com.nowjava; import java.io.File; import java.net.URL; public class Main { public static void main(String[] argv) throws Exception { Class testClass = String.class; System.out.println(getClassDirectory(testClass)); } public static String getClassDirectory(Class testClass) { String resource = testClass.getSimpleName() + ".class"; URL ressourceURL = testClass.getResource(resource); String absolutPath = ressourceURL.getPath(); absolutPath = absolutPath.replace('/', File.separatorChar);//来自 时 代 Java 公 众 号 - nowjava.com absolutPath = absolutPath.replace('\\', File.separatorChar); String className = testClass.getName(); String classNamePath = className.replace('.',