笨点的方法,稍后把封装的方法加上
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
原文:http://blog.csdn.net/liwf_/article/details/19980501