cn.dreampie.common.util.properties
类 Prop

java.lang.Object
  继承者 cn.dreampie.common.util.properties.Prop

public class Prop
extends Object

Prop. Prop can load properties file from CLASSPATH or File object.


构造方法摘要
Prop(File file)
          Prop constructor.
Prop(File file, String encoding)
          Prop constructor

Example:
Prop prop = new Prop(new File("/var/config/my_config.txt"), "UTF-8");
String userName = prop.get("userName");

Prop(String fileName)
          Prop constructor.
Prop(String fileName, String encoding)
          Prop constructor

Example:
Prop prop = new Prop("my_config.txt", "UTF-8");
String userName = prop.get("userName");

prop = new Prop("com/resty/file_in_sub_path_of_classpath.txt", "UTF-8");
String value = prop.get("key");

 
方法摘要
 boolean containsKey(String key)
           
 String get(String key)
           
 String get(String key, String defaultValue)
           
 Boolean getBoolean(String key)
           
 Boolean getBoolean(String key, Boolean defaultValue)
           
 Integer getInt(String key)
           
 Integer getInt(String key, Integer defaultValue)
           
 Long getLong(String key)
           
 Long getLong(String key, Long defaultValue)
           
 Properties getProperties()
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

Prop

public Prop(String fileName)
Prop constructor.

另请参见:
Prop(String, String)

Prop

public Prop(String fileName,
            String encoding)
Prop constructor

Example:
Prop prop = new Prop("my_config.txt", "UTF-8");
String userName = prop.get("userName");

prop = new Prop("com/resty/file_in_sub_path_of_classpath.txt", "UTF-8");
String value = prop.get("key");

参数:
fileName - the properties file's name in classpath or the sub directory of classpath
encoding - the encoding

Prop

public Prop(File file)
Prop constructor.

另请参见:
Prop(java.io.File, String)

Prop

public Prop(File file,
            String encoding)
Prop constructor

Example:
Prop prop = new Prop(new File("/var/config/my_config.txt"), "UTF-8");
String userName = prop.get("userName");

参数:
file - the properties File object
encoding - the encoding
方法详细信息

get

public String get(String key)

get

public String get(String key,
                  String defaultValue)

getInt

public Integer getInt(String key)

getInt

public Integer getInt(String key,
                      Integer defaultValue)

getLong

public Long getLong(String key)

getLong

public Long getLong(String key,
                    Long defaultValue)

getBoolean

public Boolean getBoolean(String key)

getBoolean

public Boolean getBoolean(String key,
                          Boolean defaultValue)

containsKey

public boolean containsKey(String key)

getProperties

public Properties getProperties()


Copyright © 2015. All rights reserved.