Load a properties file - Real's Java How-to
Load a properties fileTag(s): Languageimport java.util.Properties; import java.io.File; import java.io.IOException; import java.io.FileInputStream; import java.net.URL; public class PropsUtils { private PropsUtils() { } /** * Load a properties file from the classpath * @param propsName * @return Properties * @throws Exception */ public static Properties load(String propsName) throws Exception { Properties props = new Properties(); URL url = ClassLoader.getSystemResource(propsName); props.load(url.openStream()); return props; } /** * Load a Properties File * @param propsFile * @return Properties * @throws IOException */ public static Properties load(File propsFile) throws IOException { Properties props = new Properties(); FileInputStream fis = new FileInputStream(propsFile); props.load(fis); fis.close(); return props; } }欢迎分享,转载请注明来源:内存溢出
评论列表(0条)