Posted on 2006-07-06 18:13 
负人博客 阅读(394) 
评论(0)  编辑  收藏  所属分类: 
JAVA技术 
			 
			
		 
		
		1 Properties类直接读取属性文件
 
public class Test {
 public static void main(String[] args) {
  InputStream is = Test.class.getResourceAsStream("nojar.properties");
  if (is == null) 
   System.out.println("文件找不到");
  Properties prop = new Properties();
  try {
   prop.load(is);
  } catch(Exception e) {
   e.printStackTrace();
  }
  System.out.println(prop.getProperty("test"));
 }
}
2 通过ResourceBundle读取属性文件
		public class Test {
 public static void main(String[] args) {
  ResourceBundle rb = ResourceBundle.getBundle("test");
  System.out.println(rb.getString("test"));
 }
}