Class StringUtil

java.lang.Object
com.seibel.distanthorizons.coreapi.util.StringUtil

public class StringUtil extends Object
Miscellaneous string helper functions.
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • nthIndexOf

      public static int nthIndexOf(String str, String substr, int n)
      Returns the n-th index of the given string.

      Original source: https://stackoverflow.com/questions/3976616/how-to-find-nth-occurrence-of-character-in-a-string
    • join

      public static <T> String join(String delimiter, T[] list)
      See Also:
    • join

      public static <T> String join(String delimiter, Iterable<T> list)
      Combines each item in the given list together separated by the given delimiter.
    • byteArrayToHexString

      public static String byteArrayToHexString(byte[] bytes)
      Converts the given byte array into a hex string representation.
      source: https://stackoverflow.com/a/9855338
    • shortenString

      public static String shortenString(String str, int maxLength)
      Returns a shortened version of the given string that is no longer than maxLength.
      If null returns the empty string.
    • convertBytesToHumanReadable

      public static String convertBytesToHumanReadable(long bytes)
      Source: https://stackoverflow.com/questions/3758606/how-can-i-convert-byte-size-into-a-human-readable-format-in-java#3758880