Chinaunix首页 | 论坛 | 博客
  • 博客访问: 677502
  • 博文数量: 194
  • 博客积分: 3831
  • 博客等级: 中校
  • 技术积分: 1843
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-28 13:24
文章分类

全部博文(194)

文章存档

2012年(41)

2011年(42)

2010年(45)

2009年(66)

分类: Java

2012-02-21 11:48:38

package util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class GetProperty {
 private String username;
 private String password;
 private String host;
 private String port;
 private String DBName;
 private String company;
 private String parent_wbs_id;
 private InputStream inputFile;
 public String getUsername() {
  return username;
 }
 public String getPassword() {
  return password;
 }
 public String getHost() {
  return host;
 }
 public String getPort() {
  return port;
 }
 public String getDBName() {
  return DBName;
 }
 public String getCompany() {
  return company;
 }
 public String getParent_wbs_id() {
  return parent_wbs_id;
 } 
 //读取配置文件
 public boolean getProterties(){
   Properties propertie=new Properties();
   try {
    inputFile= GetProperty.class.getResourceAsStream("DB.properties");
    propertie.load(inputFile);
    username=propertie.getProperty("username");
    password=propertie.getProperty("password");
    host=propertie.getProperty("host");
    port=propertie.getProperty("port");
    DBName=propertie.getProperty("DBName");
    //company=propertie.getProperty("company");
    //parent_wbs_id=propertie.getProperty("parent_wbs_id");
    inputFile.close();
   } catch (IOException e) {
    Log.setLog("读取配置文件出错!请查看DB.properties文件是否配置正确!");
    return false;
   } 
  return true;
 }
  
  public static String toUnicode(String s) {  
      String as[] = new String[s.length()];  
      String s1 = "";  
      for (int i = 0; i < s.length(); i++) {  
          as[i] = Integer.toHexString(s.charAt(i) & 0xffff);  
          s1 = s1 + "" + as[i];  
      }  
      return s1;  
  }
 
}
阅读(548) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~