你的代码中好像并没有去找属性文件呀。如果你没有别的代码的话。
属性文件应该跟Untitled1.class放在同一个目录下,如果Untitled1.clss属于某一个包,则要将属性文件放在包的起始目录下。且Classpath中要有加上.;(代表当前目录).

解决方案 »

  1.   

    和读取文件放在同一个位置,同一个包。
    上面代码路径没改好,应该是这个:
    public class Untitled1 {
        public static void main(String[] args) {
            ResourceBundle messages = ResourceBundle.getBundle("untitled");
            String message = messages.getString("greetings");        System.out.println(message);    
        }
    }
      

  2.   

    如果你坚持这样写,把你的属性文件放在classes目录下!明白我的意思吗?
    而不是跟java文件放在一个目录下
      

  3.   

    支持楼上的说法。属性文件应该和Class放在一起。而且要在Classpath中加当前目录。
      

  4.   

    public static final ResourceBundle getBundle(String baseName)
    Gets a resource bundle using the specified base name, the default locale, and the caller's class loader. Calling this method is equivalent to calling 
    getBundle(baseName, Locale.getDefault(), this.getClass().getClassLoader()), 
    except that getClassLoader() is run with the security privileges of ResourceBundle. See getBundle for a complete description of the search and instantiation strategy. Parameters:
    baseName - the base name of the resource bundle, a fully qualified class name
      

  5.   

    yun 给你分没问题啊!结帐以后就不能讨论了,我还有些问题想全部搞清楚
      

  6.   

    1.除了楼的方法外,还可以如下操作:
      FileInputStream fis = new FileInputStream(propertyFile);
      Properties mProperties = new Properties();
      mProperties.load(fis); //属性信息与文件内容帮邦定
      fis.close();2.保存属性文件可以利用:
      mProperties.store(FileOutputStream file,String header);
      

  7.   

    是使用ResourceBundle messages = ResourceBundle.getBundle("mesages");还是
    使用FileInputStream 和Properties的load功能,看楼主的配置文件在系统中是怎么个处理法了。
      

  8.   

    import java.util.ResourceBundle;
    public class Untitled1 {
        public static void main(String[] args) {
            ResourceBundle messages = ResourceBundle.getBundle("mesages");
            String message = messages.getString("greetings");        System.out.println(message);    
        }
    }
    资源文件命名和读取顺序如下:
    filename_contry_language_x.properties
    filename_contry_language.properties
    filename_contry.properties
    filename.properties首先,getBundle("message")里面的message应该换成“filename”
    getString("greetings")里面的greetings应该写成filename.value value即你需要读取的那个key
    楼主把Locale设置成Locale.ENGLISH,就能运行了,有空我会给你个例子的