⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serverutils.java

📁 这是本人曾经在公司里用的,内部开发框架,基于struts+hibernate今天分享给大家
💻 JAVA
字号:
package cn.bway.common;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author Kson
 *
 */
public class ServerUtils {
	public static String USER = "";

	public static String PWD = "";

	public static String DEPT_PLAN_CODE = "";

	public static String MAIL_HOST = "";

	public static String MAIL_USER = "";

	public static String MAIL_PWD = "";

	public static String MAIL_NAME = "";

	public static String URL = "";

	public static String SERVER_PORT = "";

	public static int MAIL_DATE = 0;

	public static String COMPANY_NAME = "";

	public static String COMPANY_CODE = "";

	public final static String DRVER = "oracle.jdbc.driver.OracleDriver";

	private final static String enc = System.getProperty("file.encoding");

	private final static String FS = System.getProperty("file.separator");

	private final static String lSeparator = System
			.getProperty("line.separator");

	private final static boolean isGBK = enc.indexOf("GB") >= 0;

	private static String hostName = null;

	private static String hostIP = null;

	public static String getServerEncode() {
		return enc;
	}

	/**
	 * 以GBK为标准,返回服务器系统的编码变量的boolean型
	 * @return boolean true ---是GBK编码  false---非GBK编码
	 */
	public static boolean isGBKsystem() {
		return isGBK;
	}

	/**
	 * 获取服务器的文件分割符
	 * @return String
	 */
	public static String getSysFileSeparator() {
		return FS;
	}

	/**
	 * 获取服务器文件换行符
	 * @return String
	 */
	public static String getLineSeparator() {
		return lSeparator;
	}

	/**
	 * 获取服务器所在机器IP地址
	 * @throws UnknownHostException
	 * @return String IP地址
	 */
	public static String getLocalIP() throws UnknownHostException {
		if (hostIP == null) {
			hostIP = InetAddress.getLocalHost().getHostAddress();
		}
		return hostIP;
	}

	/**
	 * 获取服务器所在主机的主机名称
	 * @throws UnknownHostException 作为common下的util,不作任何异常处理,直接抛出
	 * @return String
	 */
	public static String getHostName() throws UnknownHostException {
		if (hostName == null) {
			hostName = java.net.InetAddress.getLocalHost().getHostName();
		}
		return hostName;
	}

}

⌨️ 快捷键说明

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