import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class readproperties { public static void main(String[] args) { //配置文件放在src下 InputStream inStream= (InputStream) readproperties.class.getClassLoader(). getResourceAsStream("ApplicationResources.properties");//.ApplicationResources.properties Properties properties=new Properties(); try { properties.load(inStream); } catch (IOException e) { e.printStackTrace(); } String value=properties.getProperty("key"); System.out.println("getProperty...................."+value); } }
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/10983.html