package com.vci.server.volume.uitls; import java.io.File; import java.io.FileInputStream; import java.util.Properties; public class VolumeProperties { private static String fileName = "properties/volume.properties"; private static Properties confProperties = null; static { try { File file = new File(fileName); if (file.exists()) { FileInputStream confPropertiesStream = new FileInputStream(fileName); confProperties = new Properties(); confProperties.load(confPropertiesStream); } else { VolumeWithLog4j.logger.error("没找到卷配置文件:" + file.getPath()); } } catch(Exception ee) { ee.printStackTrace(); VolumeWithLog4j.logger.error("初始化卷配置文件出错,请检查文件后重新启动", ee); } } /* * 获取指定项卷服务名称 */ public static String VolumeServiceName() { String strKey = "volume.service.name"; return getStrPro(strKey); } public static int blockLength(){ int size = getIntPro("blockLength"); if (size <= 0) size = 32; return size; } public static boolean isFileEncry(){ String encry = getStrPro("isFileEncry"); if (encry.compareToIgnoreCase("true") == 0){ return true; } return false; } public static boolean isReadOnly(){ String encry = getStrPro("isReadOnly"); if (encry.compareToIgnoreCase("true") == 0){ return true; } return false; } public static int historyCopyCount(){ return getIntPro("historyCopyCount"); } /* * 私有方法,获取字符创配置 */ private static String getStrPro(String key){ String rs = null; try{ if (confProperties != null){ rs = confProperties.getProperty(key); } }catch(Exception e){ rs = ""; } finally { if (rs == null) { rs = ""; } } return rs; } private static int getIntPro(String key){ try{ return Integer.valueOf(getStrPro(key)).intValue(); }catch(Exception e){ return -1; } } }