config.java
来自「用实例描述了factory设计模式。 并且该实例都已编译通过」· Java 代码 · 共 24 行
JAVA
24 行
package cn.edu.hunnu.factory;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
public class Config {
private static Properties p;//store the relationship of product and factory
public static void init() {
try {
File f = new File("config.properties");//construct a file from config.properties
FileInputStream fs = new FileInputStream(f);
p = new Properties();
p.load(fs);//load the relationship of product and factory from f
fs.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public static Properties getP(){
return p;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?