代碼結構如下:
demo
--src
--conf
----aaa.properties
1 Properties props = new Properties(); 2 try { 3 String url = RemoteFilter.class.getClassLoader().getResource("/").toURI().getPath()+"aaa.properties"; 4 InputStream in = new FileInputStream(new File(url)); 5 props.load(in); 6 } catch (IOException e) { 7 e.printStackTrace(); 8 } catch (URISyntaxException e) { 9 e.printStackTrace(); 10 } 11 12 String value = props.getProperty("key");