随笔-0  评论-2  文章-61  trackbacks-0

//=================sprin配置文件================================
<bean
  id="userService"
  class="com.thtf.ezone.ezesb.jmx.admin.service.impl.UserServiceImpl">
  <property
   name="filePath"
   value="config/userInfo.properties" />
 </bean>

//=================java文件================================

package com.thtf.ezone.ezesb.jmx.admin.service.impl;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class UserServiceImpl implements UserService {

String filePath = null;

 public void setFilePath(String filePath) {
  this.filePath = filePath;
 }

public static void main(String dd[])throws Exception{

Properties p = new Properties();
FileInputStream ferr=new FileInputStream((getClass().getClassLoader()
     .getResource("") + filePath).toString().substring(6));// 用subString(6)去掉:file:/try{
p.load(ferr);
ferr.close();
Set s = p.keySet();
Iterator it = s.iterator();
while(it.hasNext()){
String id = (String)it.next();
String value = p.getProperty(id);
System.out.println(id+":="+value);
}
}catch(Exception e){
e.printStackTrace();
}
}
}

//==============databaseconfing.properties 文件=====================

#----------------------------------
# sql server 2000数据厍连接信息
#----------------------------------
dp.sd.DataBaseTyp=mssql
DataBaseHost=127.0.0.1:1433
DataBase=formpro
UserName=sa
PassWord=01
#----------------------------------
# mysql 数据厍连接信息
#----------------------------------
#DataBaseHost=127.0.0.1:3306
#DataBaseTyp=mysql
#DataBase=snow
#UserName=root
#PassWord=01
//==========================运行结果=======================

PassWord:=01
DataBaseHost:=127.0.0.1:1433
DataBase:=formpro
dp.sd.DataBaseTyp:=mssql
UserName:=sa

posted on 2006-10-27 10:42 comchyi 阅读(316) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: