??? 這個也是以前寫的一點東西,今天要用,又扒出來了。希望能給大家帶來幫助:
?1?
?2?public?class?GetPath?{
?3?????public?static?void?main(String[]?args)?{
?4?????????GetPath?test?=?new?GetPath();
?5?????????System.out.println(test.getPath());
?6?????}
?7?????
?8?????public?String?getPath()?{
?9?????????return?this.getClass().getResource("/").getPath();
10?????}
11?}
12?
?2?public?class?GetPath?{
?3?????public?static?void?main(String[]?args)?{
?4?????????GetPath?test?=?new?GetPath();
?5?????????System.out.println(test.getPath());
?6?????}
?7?????
?8?????public?String?getPath()?{
?9?????????return?this.getClass().getResource("/").getPath();
10?????}
11?}
12?