java 读取资源文件的方法一:
public static String getResourceText(String key) throws IOException {
//return ResourceBundle.getBundle(resourceBundleName).getString(key);Properties prop = new Properties();//属性集合对象
File file=new File("src/Resources_en.properties");
FileInputStream fis = new FileInputStream("src/Resources_en.properties");//属性文件流
prop.load(fis);//将属性文件流装载到Properties对象中
return prop.getProperty("ProjectTitle");
}
方法二:resourceBundle方法
private static final String resourceBundleName = "edu.hust.resources.Resources";
public static String getResourceText(String key) {
return ResourceBundle.getBundle(resourceBundleName).getString(key);
}
其中src/edu/hust/resources/