java propertis使用
?
package com.risetek.webApp.gshf;import java.io.BufferedInputStream;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;import java.util.Properties;/** * <br> * description: 获取properties值,其实properties利用key和value * </br> * @author haoyf * */public class ReadProperties {private String path ="文件路径";/** * <br> * description: 通过Key获取value * </br> * @param key * properties文件中的key * @return * properties文件中的value */private String getValue(String key) {Properties property = new Properties();String value = null;InputStream in = null;try {in = new BufferedInputStream(new FileInputStream(path));property.load(in);value = property.getProperty(key);} catch (IOException e) {e.printStackTrace();} finally {try {in.close();} catch (IOException e) {e.printStackTrace();}}return value;}/** * @param args */public static void main(String[] args) {ReadProperties rp = new ReadProperties();String value = rp.getValue("key");System.out.println(value);}}