Commit 172ae0d411df8e9f963efb98fc288191d1ba466e
1 parent
dd411f29
读取配置文件
Showing
1 changed file
with
25 additions
and
0 deletions
src/main/java/com/bsth/util/Tools.java
0 → 100644
| 1 | +package com.bsth.util; | |
| 2 | + | |
| 3 | +import java.io.IOException; | |
| 4 | +import java.util.Properties; | |
| 5 | + | |
| 6 | +public class Tools { | |
| 7 | + private static Properties p = new Properties(); | |
| 8 | + private static String f; | |
| 9 | + public Tools(String file){ | |
| 10 | + f = file; | |
| 11 | + try { | |
| 12 | + p.load(Tools.class.getClassLoader().getResourceAsStream(f)); | |
| 13 | + } catch (IOException e) { | |
| 14 | + e.printStackTrace(); | |
| 15 | + } | |
| 16 | + } | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 根据key得到value的值 | |
| 20 | + */ | |
| 21 | + public String getValue(String key) | |
| 22 | + { | |
| 23 | + return p.getProperty(key); | |
| 24 | + } | |
| 25 | +} | ... | ... |