java.util.ResourceBundle以下是节选自文档:
Unlike other types of resource bundle, you don't subclass PropertyResourceBundle. Instead, you supply properties files containing the resource data. ResourceBundle.getBundle() will automatically look for the appropriate properties file and create a PropertyResourceBundle that refers to it. The resource bundle name that you pass to ResourceBundle.getBundle() is the file name of the properties file, not the class name of the object that is returned. For example, if you say ResourceBundle.getBundle("MyResources", new Locale("fr", "FR")); the resource bundle lookup mechanism will search the class path for a file called MyResources_fr_FR.properties

解决方案 »

  1.   

    SORRY!java.util.PropertyResourceBundle
      

  2.   

    给你个例子:
    //PTest.java
    import java.util.*;
    import java.io.*;
    public class PTest
    {
    public static void main(String[] args)
    {
    try
    {
    PropertyResourceBundle p=new PropertyResourceBundle(new FileInputStream("test.properties"));
    String name=(String)p.handleGetObject("name");
    System.out.print("name= "+name);
    }catch(Exception e){e.printStackTrace();}
    }
    }然后在同目录建立test.properties文件,文件内容如下:
    name=xioyoo
    age=21
    school=uestc你自己编译运行一下就知道了。
      

  3.   

    to:xioyoo(丁鹏)
    我可能没有表达清楚我的意图:把程序中改变过的参数保存下来.
    比如本来是name=xioyoo,我在程序中改变了它:name=YYY;怎么样把它保存到属性文件中?
      

  4.   

    to:xioyoo(丁鹏)
    java.util.Properties的void store(OutputStream out, String header)你看怎么样?
      

  5.   

    ResourceBundle一般都是只读的,因为它的值可能影响其他的类,所以一般server启动后,这些值就不能变了。
    而Properties也可以从InputStream, -D等方式中取出,作用于内存中,也就是说它允许你修改,但仅限于内存中,不能写到硬盘中。
      

  6.   

    import java.util.*;
    import java.io.*;
    public class PropertyTest
    {
    public static void main(String[] args)
    {
    Properties ps=new Properties();
    ps.put("name","xioyoo");
    ps.put("age","21");
    ps.put("school","uestc");
    ps.put("email","[email protected]");
    try
    {
    ps.store(new FileOutputStream("Property.txt"),"this is my base info");
    }
    catch(Exception e){e.printStackTrace();}
    System.out.println("write ok!");

    }
    }在同目录下面建立一个Property.txt文件。