标签:ati inpu oid ring config print exception util 添加
1、先在项目中创建一个包(如:config),再创建一个配置文件(如:a.properties),添加配置信息如下:
比如
name=kaka
age=28
2.代码:
import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class PropertyTest { public static void main(String[] args) { PropertyTest loadProp = new PropertyTest(); InputStream in = loadProp.getClass().getResourceAsStream("/config/a.properties"); Properties prop = new Properties(); try { prop.load(in); } catch (IOException e) { e.printStackTrace(); } System.out.println(prop.getProperty("name")); System.out.println(prop.getProperty("age")); } }
标签:ati inpu oid ring config print exception util 添加
原文地址:http://www.cnblogs.com/rain-in-summer/p/7381954.html