Properties prop = new Properties();
ClassPathResource resource = new ClassPathResource("monitor.properties");
// 载入prop文件
prop.load(resource.getInputStream());
String url = prop.getProperty("spMonitorUrl").trim();
URL spUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) spUrl.openConnection();
//得到输入流
InputStream xml = conn.getInputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(in));
StringBuilder result = new StringBuilder();
String s=null;
while((s = br.readLine()) != null){
result.append(s)
in.close();
}
System.out.println(result);
使用Java读取properties文件
最新推荐文章于 2024-05-24 10:49:58 发布