Class PropertiesUtils

java.lang.Object
cn.xuanyuanli.core.util.PropertiesUtils

public class PropertiesUtils extends Object
properties工具
Author:
John Li
  • Field Details

    • HEX_DIGIT

      private static final char[] HEX_DIGIT
      A table of hex digits
  • Constructor Details

    • PropertiesUtils

      public PropertiesUtils()
  • Method Details

    • saveProperties

      public static void saveProperties(String descPath, List<String> content, boolean escapeUnicode)
      保存内容到相应路径
      Parameters:
      descPath - 目标路径
      content - 内容
      escapeUnicode - val是否转换为unicode
    • keySaveConvert

      public static String keySaveConvert(String key)
      键保存转换
      Parameters:
      key - 键
      Returns:
      String
      See Also:
    • valueSaveConvert

      public static String valueSaveConvert(String val)
      值保存转换
      Parameters:
      val - 值
      Returns:
      String
      See Also:
    • saveConvert

      private static String saveConvert(String theString, boolean escapeSpace, boolean escapeUnicode)
      对key和value特殊字符进行转义,参考Properties中的此方法
      Parameters:
      theString - 字符串
      escapeSpace - 逃避空间
      escapeUnicode - 逃避unicode
      Returns:
      String
    • toHex

      private static char toHex(int nibble)
      Convert a nibble to a hex character
      Parameters:
      nibble - the nibble to convert.
      Returns:
      char
    • loadConvert

      private static String loadConvert(char[] in, int off, int len, char[] convtBuf)
      from java.util.Properties#loadConvert copy
      Parameters:
      in - 在
      off - 从
      len - len
      convtBuf - convt缓冲区
      Returns:
      String
    • loadTreeMapFromClasspath

      public static TreeMap<String,String> loadTreeMapFromClasspath(String propertiesPath)
      加载classpath下的properties文件,返回有序的map
      Parameters:
      propertiesPath - 属性路径
      Returns:
      TreeMapinvalid input: '<'String, String>
    • loadTreeMapFromFile

      public static TreeMap<String,String> loadTreeMapFromFile(String propertiesPath)
      加载classpath下的properties文件,返回有序的map
      Parameters:
      propertiesPath - 属性路径
      Returns:
      TreeMapinvalid input: '<'String, String>
    • load0

      private static void load0(PropertiesUtils.LineReader lr, TreeMap<String,String> treeMap) throws IOException
      from java.util.Properties#load0(Properties.LineReader) copy
      Parameters:
      lr - lr
      treeMap - 树map
      Throws:
      IOException - ioexception