读取属性文件内容

public class Client {
/**
* socket的连接参数属性文件
*/
private final String propFile = "/com/coruninfo/zs/tax/banksocket/handler/client.properties";//属性文件地址

Properties prop = new Properties();

InputStream input = Client.class.getResourceAsStream(propFile);//Client.class是当前类名
prop.load(input);
String IP = prop.getProperty("ip");
int PORT = Integer.parseInt(prop.getProperty("port"));
int TIMEOUT = Integer.parseInt(prop.getProperty("timeOut"));
System.out.println(IP + " , " + PORT + " , " + TIMEOUT);

}

posted @ 2017-11-13 15:25  橘子和西红柿  阅读(186)  评论(0编辑  收藏  举报