java获取src下的properties文件的值

1. java获取src下的properties文件的值

Properties properties = new Properties();

String base = new Thread().getContextClassLoader().getClass().getResource("/").getPath();
File urlFile = new File(base + "/url.properties");
properties.load(new FileInputStream(urlFile));
String URL = properties.getProperty("url").trim();
System.out.println(URL);

你可能感兴趣的:(java)