我有一个非常简单的属性文件测试,我试图让工作:(下面是TestProperties.java)将.properties文件放在Eclipse项目中的位置?
package com.example.test;
import java.util.ResourceBundle;
public class TestProperties {
public static void main(String[] args) {
ResourceBundle myResources =
ResourceBundle.getBundle("TestProperties");
for (String s : myResources.keySet())
{
System.out.println(s);
}
}
}
和TestProperties.properties在同一目录下:
something=this is something
something.else=this is something else
我也保存为TestProperties_en_US.properties
当我从Eclipse中运行TestProperties.java,它无法找到属性文件:
java.util.MissingResourceException:
Can't find bundle for base name TestProperties, locale en_US
我做错了什么?