public class PropKit extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static Prop |
append(File file) |
static Prop |
append(File file,
String encoding) |
static Prop |
append(Prop prop) |
static Prop |
append(String fileName) |
static Prop |
append(String fileName,
String encoding) |
static Prop |
appendIfExists(File file) |
static Prop |
appendIfExists(File file,
String encoding) |
static Prop |
appendIfExists(String fileName) |
static Prop |
appendIfExists(String fileName,
String encoding) |
static void |
clear() |
static boolean |
containsKey(String key) |
static String |
get(String key) |
static String |
get(String key,
String defaultValue) |
static Boolean |
getBoolean(String key) |
static Boolean |
getBoolean(String key,
Boolean defaultValue) |
static Double |
getDouble(String key) |
static Double |
getDouble(String key,
Double defaultValue) |
static String |
getEnv() |
static String |
getEnvKey() |
static Integer |
getInt(String key) |
static Integer |
getInt(String key,
Integer defaultValue) |
static Long |
getLong(String key) |
static Long |
getLong(String key,
Long defaultValue) |
static Prop |
getProp() |
static Prop |
getProp(String fileName) |
static void |
setEnvKey(String envKey)
设置环境 key,PropKit 将通过该 key 获取环境 value。
|
static Prop |
use(File file)
Use the properties file bye File object.
|
static Prop |
use(File file,
String encoding)
Use the properties file bye File object.
|
static Prop |
use(String fileName)
Use the properties file.
|
static Prop |
use(String fileName,
String encoding)
Use the properties file.
|
static Prop |
useFirstFound(String... fileNames)
Use the first found properties file
|
static Prop |
useless(String fileName) |
public static void setEnvKey(String envKey)
public static String getEnvKey()
public static String getEnv()
public static Prop use(String fileName)
use(String, String)public static Prop use(String fileName, String encoding)
Example:
PropKit.use("config.txt", "UTF-8");
PropKit.use("other_config.txt", "UTF-8");
String userName = PropKit.get("userName");
String password = PropKit.get("password");
userName = PropKit.use("other_config.txt").get("userName");
password = PropKit.use("other_config.txt").get("password");
PropKit.use("com/jfinal/config_in_sub_directory_of_classpath.txt");
fileName - the properties file's name in classpath or the sub directory of classpathencoding - the encodingpublic static Prop use(File file)
use(File, String)public static Prop use(File file, String encoding)
Example:
PropKit.use(new File("/var/config/my_config.txt"), "UTF-8");
Strig userName = PropKit.use("my_config.txt").get("userName");
file - the properties File objectencoding - the encodingpublic static void clear()
public static Prop useFirstFound(String... fileNames)
public static Prop getProp()
public static boolean containsKey(String key)
Copyright © 2024. All rights reserved.