Java读取classpath中配置文件的小例子
2016-10-15 21:27
344 查看
import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class PropLoad { private static Properties p = new Properties(); static { InputStream in = PropLoad.class.getClassLoader().getResourceAsStream("test.properties"); try { p.load(in); } catch (IOException e) { _INFO_STATIC("load Properties failed"); } } public static String getKey(String key){ return p.getProperty(key); } public static void main(String[] agrs){ System.out.println(PropLoad.getKey("test")); } }
相关文章推荐
- java中读取配置文件的方法fileSystemXmlapplicationContext与classPathXmlApplicationContext
- JAVA classpath和classpath*和配置文件路径的关系
- ClassPathXmlApplicationContext方式读取配置文件
- IDEA 中读取不了配置文件以及ClassPathXmlApplicationContext与FileSystemXmlApplicationContext
- java中Class.getResource用法(用于配置文件的读取)
- ClassLoader.getResourceAsStream(name); ---java读取配置文件
- SpringBoot读取配置文件(从classpath/file读取yml/properties文件)
- Java 读取ClassPathXmlApplicationContext xml 文件里面的bean
- java中经常用到的读写配置文件的信息properties属性的写入,读取例子
- eclipse 打包 jar 读取外部的配置文件 图片等 fatjar MANIFEST.MF Class-Path
- java中经常用到的读写配置文件的信息properties属性的写入,读取例子
- Java简单读取classpath下面的文件
- Jar内外配置文件的读取public class JarReader { public static void main(String[] args) { String jarPath = "C
- Spring ClassPathXmlApplicationContext和FileSystemXmlApplicationContext读取配置文件的方法
- java中读取配置文件中的数据
- java读取配置文件的几种方法
- 为什么java读取配置文件,中文这样不会出现乱码
- Java中加载配置文件的集中方式,以及利用ClassLoader加载文件 .
- java 用单态方式实现数据库配置文件读取
- Java中dom4j读取配置文件实现抽象工厂+反射