原来这样读取属性文件的内容呀

public class SiteUrl {
 public static String readUrl(String key){
  Properties properties = new Properties();
  try {
   properties.load(SiteUrl.class.getClassLoader().getResourceAsStream("siteurl.properties"));
  } catch (IOException e) {
   e.printStackTrace();
  }
  return (String)properties.getProperty(key);
 }
}

你可能感兴趣的:(文件)