Java读取Properties文件
import java.io.IOException;import java.io.InputStream;import java.util.Properties;/** * properties文件操作类 * * @author wsz * @createTime 2012-4-12 * @version 1.0 */public class PropertiesUtil {private static Properties properties = new Properties();private static InputStream inputStream = PropertiesUtil.class.getResourceAsStream("/sourceSystem.properties");/** * 通过key获取对应的value * * @param key * @return */ public static String getSourceSystemValue(String key) {try {properties.load(inputStream);} catch (IOException e) {e.printStackTrace();}return properties.getProperty(key); }}
?