From bbb29c3dc7f3a421e2a045a14be29672a7fda62d Mon Sep 17 00:00:00 2001 From: oeljeklaus-you Date: Thu, 21 Jun 2018 22:52:21 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=8E=AF=E5=A2=83=E6=90=AD=E5=BB=BA=E5=AE=8C?= =?UTF-8?q?=E6=88=90=202.=E7=9B=B8=E5=85=B3=E7=9A=84=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB=E7=BC=96=E5=86=99=E5=AE=8C=E6=88=90=203.=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86=E7=B1=BB=E7=BC=96?= =?UTF-8?q?=E5=86=99=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/uiDesigner.xml | 124 ++++++++++++++++++ .idea/vcs.xml | 6 + .idea/workspace.xml | 75 ++++++++--- .../edu/hust/conf/ConfigurationManager.java | 38 ++++++ 4 files changed, 228 insertions(+), 15 deletions(-) create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 src/main/java/cn/edu/hust/conf/ConfigurationManager.java diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4c9c1a9..61a0ff1 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,12 @@ - + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + @@ -96,6 +113,7 @@ + @@ -253,16 +271,15 @@ - - @@ -273,11 +290,11 @@ - + - + @@ -359,6 +376,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/cn/edu/hust/conf/ConfigurationManager.java b/src/main/java/cn/edu/hust/conf/ConfigurationManager.java new file mode 100644 index 0000000..355ca0d --- /dev/null +++ b/src/main/java/cn/edu/hust/conf/ConfigurationManager.java @@ -0,0 +1,38 @@ +package cn.edu.hust.conf; + +import java.io.InputStream; +import java.util.Properties; + +/** + * 配置文件管理类 + * 主要的功能:从特定的properties文件中读取相应的key/value + */ +public class ConfigurationManager { + private static Properties prop=new Properties(); + + /** + * 通过静态代码块加载配置文件 + */ + static{ + try + { + //通过类的加载器读取配置文件 + InputStream is=ConfigurationManager.class.getClassLoader().getResourceAsStream("conf.properties"); + //加载配置文件 + prop.load(is); + }catch(Exception e) + { + e.printStackTrace(); + } + } + + /** + * 通过指定的key获取value + * @param key + * @return + */ + public static String getProperty(String key) + { + return prop.getProperty(key); + } +}