Class StringUtil

java.lang.Object
de.tilman_neumann.util.StringUtil

public class StringUtil
extends java.lang.Object
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String formatLeft​(java.lang.String s, java.lang.String mask)
    Inserts a string s left-aligned into a mask, without truncation.

    Examples:
    formatLeft("abc", "123456") -> "abc456"
    formatLeft("abcdef", "123") -> "abcdef"
    static java.lang.String formatRight​(java.lang.String s, java.lang.String mask)
    Inserts a string s right-aligned into a mask, without truncation.

    Examples:
    formatRight("abc", "123456") -> "123abc"
    formatRight("abcdef", "123") -> "abcdef"
    static java.lang.String repeat​(java.lang.String s, int n)
    Concatenates string s n times.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • repeat

      public static java.lang.String repeat​(java.lang.String s, int n)
      Concatenates string s n times.
      Parameters:
      s - string to repeat
      n - number of repetitions
      Returns:
      a string resulting from n repetitions of s, or null if n <= 0
    • formatLeft

      public static java.lang.String formatLeft​(java.lang.String s, java.lang.String mask)
      Inserts a string s left-aligned into a mask, without truncation.

      Examples:
      formatLeft("abc", "123456") -> "abc456"
      formatLeft("abcdef", "123") -> "abcdef"
      Parameters:
      s -
      mask -
      Returns:
      s left-aligned in mask
    • formatRight

      public static java.lang.String formatRight​(java.lang.String s, java.lang.String mask)
      Inserts a string s right-aligned into a mask, without truncation.

      Examples:
      formatRight("abc", "123456") -> "123abc"
      formatRight("abcdef", "123") -> "abcdef"
      Parameters:
      s -
      mask -
      Returns:
      s right-aligned in mask