java学习(177):获取应用程序的路径
生活随笔
收集整理的這篇文章主要介紹了
java学习(177):获取应用程序的路径
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
import javax.tools.Tool;
import java.net.URLDecoder;//獲取類路徑
public final class test132 {public static String getClassPath(){String path=test132.class.getClassLoader().getResource( "" ).getPath().toString();try {return URLDecoder.decode( path,"UTF-8" );}catch (Exception e){e.printStackTrace();}return path;}
}
上面編寫方法
?
定義一個實現(xiàn)類
import javax.tools.Tool; //獲取文件程序類的路徑 public class test133 {public static void main(String[] args){String classPath=test132.getClassPath();System.out.println( classPath );} }運行結果
總結
以上是生活随笔為你收集整理的java学习(177):获取应用程序的路径的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: UltraISO 9.7.0.3476中
- 下一篇: 布法罗博士计算机专业回国人员,四名UW学