1

为什么保存后我的属性文件在eclipse项目中显示为.properties.txt。我已将文件放置在我的包的 src 文件夹中,但仍然为找不到 bundle 抛出异常。

package array;
import java.util.*;
public class AddingToList {
static public void main(String[] args) {

    String language;
    String country;

    if (args.length != 2) {
        language = new String("en");
        country = new String("US");
    } else {
        language = new String(args[0]);
        country = new String(args[1]);
    }

    Locale currentLocale;
    ResourceBundle messages;

    currentLocale = new Locale(language, country);

    messages = ResourceBundle.getBundle("MessagesBundle", currentLocale);
    System.out.println(messages.getString("greetings"));
    System.out.println(messages.getString("inquiry"));
    System.out.println(messages.getString("farewell"));
}

}

4

1 回答 1

0

从评论到回答并等待接受:

消息包必须在“默认包”中+对包的调用应该是"/MessagesBundle"

于 2013-10-30T12:49:41.677 回答