读取属性文件内容

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);

}

原文地址:https://www.cnblogs.com/jzhxhs/p/7826526.html