读取工程下指定路径文件

来源:互联网 发布:直播 杭州 人工智能 编辑:程序博客网 时间:2024/06/05 15:24
package com.kingdee.eas.cp.trd.webservice.taskinter;import java.io.IOException;import java.io.InputStream;import java.util.Properties;public class TaskInteConfigUtil {public static String hostAdress;public static int port;public static int clientTimeout;    public static String appId;static{Properties props = new Properties();ClassLoader classLoader = TaskInteConfigUtil.class.getClassLoader();InputStream in = null;try {in = classLoader.getResourceAsStream("com/kingdee/eas/cp/trd/webservice/taskinter/TastInterConfig.properties");props.load(in);hostAdress = props.getProperty("hostAdress");port = Integer.valueOf(props.getProperty("port"));clientTimeout = Integer.valueOf(props.getProperty("clientTimeout"));appId = props.getProperty("appId");} catch (Exception e) {e.printStackTrace();}finally{if(in != null){try {in.close();} catch (IOException e) {e.printStackTrace();}}}}}

0 0
原创粉丝点击