ResourceBundle的路径问题
?來源:http://www.diybl.com/course/3_program/java/javajs/200862/119502.html
?
System.out.println(System.getProperty("user.dir"));? //這個是去工程的絕對路徑的
??System.out.println(Thread.currentThread().getContextClassLoader().getResource(""));//這個是去當前classpath的uri的!
??new Properties().load(new FileInputStream("test.properties"));//這里說明test文件在工程的跟目錄下!
new Properties().load(new FileInputStream("test/test.properties"));//說明,在工程底下的test的文件夾底下的文件test.properties!
??ResourceBundle rs = ResourceBundle.getBundle("org.hello");//這里說明,hello文件就是在于classpath底下的,org 包底下有這個文件hello.properties~也就是說.../bin/這個是classpath絕對路徑!
總結
以上是生活随笔為你收集整理的ResourceBundle的路径问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一个Java反射机制例子
- 下一篇: 标签的使用