码迷,mamicode.com
首页 > 其他好文 > 详细

读取.properties配置文件

时间:2015-01-23 12:38:14      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:

文件内容:

url=jdbc:oracle:thin:@192.168.1.222:1521:orcl
userName=dwp
passWord=ghc_211
driverName=oracle.jdbc.driver.OracleDriver

 

package util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;

public class Test{
    public static void main (String[] args) throws IOException{
        Properties pro = new Properties();
        FileInputStream in =null;
        try{
            in = new FileInputStream("config\\db.properties");
        }catch (FileNotFoundException e){
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        pro.load(in);
        System.out.println (pro.getProperty ("driverName"));
        
//       
    }
}

  

读取.properties配置文件

标签:

原文地址:http://www.cnblogs.com/staryy/p/4243633.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!