Java Properties文件的读取

1. 使用ResourceBundle

 

ResourceBundle rb = ResourceBundle.getBundle("jdbcPath");
		String filePath = rb.getString("filePath");
 

 

2. 使用自带的Properties 类

 

 

 

try {   
            InputStream in = new BufferedInputStream(new FileInputStream(   
                    PROPERTY_FILE));   
            props.load(in);   
            in.close();   
            String value = props.getProperty(key);   
            return value;   
        } catch (Exception e) {   
            e.printStackTrace();   
            return null;   
        }
 

 

你可能感兴趣的:(java properties)