Class StringUtil

java.lang.Object
tools.StringUtil

public class StringUtil extends Object
Provides a suite of utilities for manipulating strings.
Since:
Revision 336
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • getLeftPaddedStr

      public static final String getLeftPaddedStr(String in, char padchar, int length)
      Gets a string padded from the left to length by padchar.
      Parameters:
      in - The input string to be padded.
      padchar - The character to pad with.
      length - The length to pad to.
      Returns:
      The padded string.
    • getRightPaddedStr

      public static final String getRightPaddedStr(String in, char padchar, int length)
      Gets a string padded from the right to length by padchar.
      Parameters:
      in - The input string to be padded.
      padchar - The character to pad with.
      length - The length to pad to.
      Returns:
      The padded string.
    • joinStringFrom

      public static final String joinStringFrom(String[] arr, int start)
      Joins an array of strings starting from string start with a space.
      Parameters:
      arr - The array of strings to join.
      start - Starting from which string.
      Returns:
      The joined strings.
    • joinStringFrom

      public static final String joinStringFrom(String[] arr, int start, String sep)
      Joins an array of strings starting from string start with sep as a seperator.
      Parameters:
      arr - The array of strings to join.
      start - Starting from which string.
      Returns:
      The joined strings.
    • makeEnumHumanReadable

      public static final String makeEnumHumanReadable(String enumName)
      Makes an enum name human readable (fixes spaces, capitalization, etc)
      Parameters:
      enumName - The name of the enum to neaten up.
      Returns:
      The human-readable enum name.
    • countCharacters

      public static final int countCharacters(String str, char chr)
      Counts the number of chr's in str.
      Parameters:
      str - The string to check for instances of chr.
      chr - The character to check for.
      Returns:
      The number of times chr occurs in str.
    • getReadableMillis

      public static final String getReadableMillis(long startMillis, long endMillis)
    • getDaysAmount

      public static final int getDaysAmount(long startMillis, long endMillis)
    • codeString

      public static String codeString(String fileName) throws FileNotFoundException
      Throws:
      FileNotFoundException
    • codeString

      public static String codeString(File file) throws FileNotFoundException
      判斷檔案的編碼格式
      Parameters:
      file - :file
      Returns:
      檔案的編碼格式
      Throws:
      FileNotFoundException