首页 > 其他 > 详细

读取properties文件值

时间:2014-02-27 17:22:22      阅读:624      评论:0      收藏:0      [点我收藏+]

笨点的方法,稍后把封装的方法加上

public class BillConfig2 {
	private static final String CONFIG_FILE_NAME="billConfig.properties";
	private static	Properties p=new Properties();
	static String path=null;     
	
	static{   
		
	     path=BillConfig2.class.getResource("/").getPath()+CONFIG_FILE_NAME;
		try {                                              
			path=URLDecoder.decode(path,"utf-8");             
			p.load(new FileInputStream(new File(path)));
			
		} catch (UnsupportedEncodingException e) {				
			e.printStackTrace();      
		} catch (FileNotFoundException e) {				
			e.printStackTrace();
		} catch (IOException e) {				
			e.printStackTrace(); 
		}
	}  
	
	public static String getLocation(){
		return p.getProperty("location");
	}
	
	public static String getSplit(){
		return p.getProperty("split");
	}
	
	public static String getLocationBack(){
		return p.getProperty("locationBack");
	}
	
	public static String getUrl(){
		return p.getProperty("url");
	}
	
	public static String getLocationError(){
		return p.getProperty("locationError");
	}
	
}


读取properties文件值,布布扣,bubuko.com

读取properties文件值

原文:http://blog.csdn.net/liwf_/article/details/19980501

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!