为什么保存后我的属性文件在eclipse项目中显示为.properties.txt。我已将文件放在我的软件包的src文件夹中,但仍然发现了未找到软件包的异常。
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"));
}
}
答案 0 :(得分:0)
从评论到回答和等待接受:
消息包必须位于“默认包”+对包的调用应为"/MessagesBundle"