1 . 使用Java.util.Properties類的load()方法
示例:
InputStream in = lnew BufferedInputStream(new FileInputStream(name));
Properties p = new Properties();
p.load(in);
2耿芹。使用java.util.ResourceBundle類的getBundle()方法
示例:
ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault());
3羡玛。使用java.util.PropertyResourceBundle類的構(gòu)造函數(shù)
示例:
InputStream in = new BufferedInputStream(new FileInputStream(name));
ResourceBundle rb = new PropertyResourceBundle(in);
4。使用class變量的getResourceAsStream()方法
示例:
Properties p = new Properties();
p.load(in);
5。使用class.getClassLoader()所得到的java.lang.ClassLoader的getResourceAsStream()方法
示例:
InputStream in = JProperties.class.getClassLoader().getResourceAsStream(name);
Properties p = new Properties();
p.load(in);
6乔妈。使用java.lang.ClassLoader類的getSystemResourceAsStream()靜態(tài)方法