30bc2ae92f410018187e8f4f0cfd5be6

来自「订餐系统」· 代码 · 共 39 行

TXT
39
字号
package Dao;

import java.util.*;
import java.io.*;

public final class Env {
	private static Env instance;
	
	public static Env getInstance()
	{
		if(instance != null)
		{
			return instance;
		}
		else
		{
			makeInstance();
			return instance;
		}
	}
	public static synchronized void makeInstance()
	{
		if(instance == null)
		{
			instance = new Env();
		}
	}
	private Env()
	{
		InputStream is = getClass().getResourceAsStream("db.properties");
		try{
			load(is);
		}catch(Exception e)
		{
			System.out.println("错误:没有读取属性文件,请确认db.properties文件是否存在");
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?