Class StringUtil


  • public class StringUtil
    extends java.lang.Object
    This class provides useful String manipulation methods
    • Constructor Summary

      Constructors 
      Constructor Description
      StringUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String insertString​(java.lang.String source, java.lang.String newEntry, int position)
      Insert a string in a middle of another string
      static boolean isEmpty​(java.lang.String source)
      Check if a string is empty or null
      static java.lang.String removeCharAt​(java.lang.String source, int position)
      Remove a character in a String
      static java.lang.String safeToString​(java.lang.Object source)
      Returns a "safe" string representation.
      static java.lang.String stackStraceAsString​(java.lang.Throwable exception)
      Converts exception stack trace as string
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StringUtil

        public StringUtil()
    • Method Detail

      • safeToString

        public static java.lang.String safeToString​(java.lang.Object source)
        Returns a "safe" string representation. If source is null, return an empty string
        Parameters:
        source - source string
        Returns:
        the string representation of the source (without space) if the source is not null, or an empty string otherwise
      • isEmpty

        public static boolean isEmpty​(java.lang.String source)
        Check if a string is empty or null
        Parameters:
        source - source string
        Returns:
        true is the string is empty or null, false otherwise
      • stackStraceAsString

        public static final java.lang.String stackStraceAsString​(java.lang.Throwable exception)
        Converts exception stack trace as string
        Parameters:
        exception - exception to convert
        Returns:
        a string that contains the exception
      • insertString

        public static java.lang.String insertString​(java.lang.String source,
                                                    java.lang.String newEntry,
                                                    int position)
        Insert a string in a middle of another string
        Parameters:
        source - source string
        newEntry - string to insert into source
        position - position to insert source
        Returns:
        the new string
      • removeCharAt

        public static java.lang.String removeCharAt​(java.lang.String source,
                                                    int position)
        Remove a character in a String
        Parameters:
        source - source string
        position - position of the character to remove
        Returns:
        the string without the character