java properties 属性,java 读取 properties 属性资料
java 讀取 properties 屬性文件
package com.xinlong.util;
import java.io.InputStream;
import java.util.Properties;
public final class Test {
public static String p1;
public static String p2;
static
{
Properties prop = new Properties();
InputStream in = Object.class.getResourceAsStream("/struts.properties");
try{
prop.load(in);
p1=prop.getProperty("path").trim();
p2=prop.getProperty("IndexDir").trim();
}catch(Exception ex)
{
}
}
private Test () {
}
/**
* @return the p1
*/
public static String getP1() {
return p1;
}
/**
* @param p1 the p1 to set
*/
public static void setP1(String p1) {
Test.p1 = p1;
}
/**
* @return the p2
*/
public static String getP2() {
return p2;
}
/**
* @param p2 the p2 to set
*/
public static void setP2(String p2) {
Test.p2 = p2;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("1======="+getP1());
System.out.println("2======"+getP2());
}
}
總結(jié)
以上是生活随笔為你收集整理的java properties 属性,java 读取 properties 属性资料的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php将数组中元素打乱顺序,PHP公开课
- 下一篇: oracle exp 二进制,Oracl