首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

治理资源文件

2012-09-06 
管理资源文件java二种方法管理资源文件1.java.util.PropertiesInputStream isnew FileInputStream(confi

管理资源文件
java二种方法管理资源文件

1.java.util.Properties

InputStream is=new FileInputStream("config.properties");Properties pro=new Properties();pro.load(is);is.close();//关闭释放系统资源String className=pro.getProperty("className");




2.采用类加载器(只能读 不能写)
//InputStream is=TestProperties.class.getClassLoader().getResourceAsStream("com/hp/reflect/config.properties");//InputStream is=TestProperties.class.getResourceAsStream("/com/hp/resource/config.properties");InputStream is=TestProperties.class.getResourceAsStream("config.properties");



com.hp.reflect
*.java
config.properties

com.hp.resource
config.properties

热点排行