巧妙装载你的properties
详细的,请访问 这里
好几种方式装载 resource 文件:
1. File 类via FileInputStream, FileReader, and RandomAccessFile)
你需要计算文件路径,是否是绝对的或相对的。所以这样做将使你的程序不易移植.
2. ClassLoader.getResourceAsStream (”some/pkg/resource.properties”);
以斜线分割包,路径是绝对的。
3. Class.getResourceAsStream (”/some/pkg/resource.properties”);
以斜线分割包,路径可以是绝对的或相对的.
4. ResourceBundle.getBundle (”some.pkg.resource”);
以点分割包,.properties 是隐含的,因为bundle可以是一个类。
By javafuns on May 12, 2006 at 10:44 ·
Views: 539 · Permalink
Categorized in: Java · Tagged with: Java
Categorized in: Java · Tagged with: Java


(
on 2009/11/18 at 22:10
· Permalink
[...] 另外请参考《巧妙装载你的properties》 [...]