Java读取properties文件工具类

mac2025-04-21  7

import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class PropertiesUtil { /** * 根据配置文件名称,返回Properties对象 * properties.getProperty("ip").trim() * @return Properties * @throws IOException */ public static Properties readProperties(String propertiesName) throws IOException{ //读取properties配置文件 Properties properties = new Properties(); InputStream is = PropertiesUtil.class.getClassLoader().getResourceAsStream(propertiesName);//new BufferedInputStream(new FileInputStream("./conf/pue_conf.properties")); properties.load(is); return properties; } }

 

最新回复(0)