两种办法,使用java.net.URL或者 System.getProperty("user.dir")
使用java.net.URL比较复杂,但存在中文问题

public static String getRealPath(String filename)...{
String path="";
Class theClass=TestHelloWorld.class;
java.net.URL u= theClass.getResource(filename);
return u.getPath();
}
1007

被折叠的 条评论
为什么被折叠?



