package com.zuidaima.util; import java.io.File; import java.io.IOException; import cn.hutool.core.util.ObjectUtil; import cn.hutool.setting.Setting; public class PropsUtil { public static Setting props = new Setting("config.setting"); // public static Setting props = new Setting(getPath() + "/config.setting"); public static final String IS_OPEN_COPY = "openCopy"; public static final String NEW_DIRS = "dirs"; public static final String IS_RENAME = "reName"; public static final String FILE_SUFFIX = "nameSuffix"; public static final String IS_UPLOAD = "isUpload"; public static final String FTP_HOST = "ftpUploadAddr"; public static final String FTP_PORT = "ftpPort"; public static final String FTP_USER = "ftpUserName"; public static final String FTP_PASS = "ftpPassword"; public static final String FTP_PATH = "ftpPath"; public static final String CHART_SET = "chartSet"; public static final String MONITOR_DIR = "monitorDir"; public static final String SECOND = "second"; public static final Integer defaultFtpPort = 21; public static final String verticalLine = "|"; public static Setting getVal() { return props; } public static String getPath(){ File directory = new File(""); try { directory.getCanonicalPath(); } catch (IOException e) { e.printStackTrace(); } String path = directory.getAbsolutePath(); return path; } public static boolean getBooleanValByProps(String key) { Object object = props.get(key); if (ObjectUtil.isEmpty(object)) { return false; } return Boolean.valueOf(object.toString()).booleanValue(); } public static int getIntegerValByProps(String key) { Object object = props.get(key); if (ObjectUtil.isEmpty(object)) { return defaultFtpPort; } return Integer.valueOf(object.toString()); } public static String getUserName() { return props.get(FTP_USER) + ""; } public static String getPassword() { return props.get(FTP_PASS) + ""; } public static Integer getPort() { return getIntegerValByProps(FTP_PORT); } public static String getBasePath() { return props.get(FTP_PATH) + ""; } public static String getChartSet() { return props.get(CHART_SET) + ""; } public static boolean isCopy() { return getBooleanValByProps(IS_OPEN_COPY); } public static boolean isUpload() { return getBooleanValByProps(IS_UPLOAD); } public static boolean isReName() { return getBooleanValByProps(IS_RENAME); } }
最近下载更多