Class StringUtils

java.lang.Object
fr.gouv.vitam.common.StringUtils

public final class StringUtils extends Object
String utils
  • Field Details

    • HTML_PATTERN

      public static final Pattern HTML_PATTERN
    • UNPRINTABLE_PATTERN

      public static final Pattern UNPRINTABLE_PATTERN
    • RULES

      public static final List<String> RULES
  • Method Details

    • checkSanityString

      public static String checkSanityString(String value) throws InvalidParseOperationException
      Check external argument to avoid Path Traversal attack
      Parameters:
      value - to check
      Throws:
      InvalidParseOperationException
    • checkSanityString

      public static void checkSanityString(String... strings) throws InvalidParseOperationException
      Check external argument
      Parameters:
      strings -
      Throws:
      InvalidParseOperationException
    • getRandom

      public static final byte[] getRandom(int length)
      Parameters:
      length - the length of rray
      Returns:
      a byte array with random values
    • getBytesFromArraysToString

      public static final byte[] getBytesFromArraysToString(String bytesString)
      Revert Arrays.toString for bytes
      Parameters:
      bytesString - the string to transform
      Returns:
      the array of bytes
      Throws:
      IllegalArgumentException - if bytesString is null or empty
    • getClassName

      public static final String getClassName(Object object)
      Parameters:
      object - to get its class name
      Returns:
      the short name of the Class of this object
    • substringBetween

      public static final String substringBetween(String source, String start, String end)
      Gets the String that is nested in between two Strings. Only the first match is returned.
      Parameters:
      source -
      start -
      end -
      Returns:
      the substring, null if no match
    • substringBeforeLast

      public static final String substringBeforeLast(String source, String separator)
      Gets the substring before the last occurrence of a separator. The separator is not returned.
      Parameters:
      source -
      separator -
      Returns:
      the substring before the last occurrence of the separator, null if null String input
    • getStringFromInputStream

      public static String getStringFromInputStream(InputStream is) throws IOException
      Get text content of an input stream
      Parameters:
      is - input stream
      Returns:
      text content
      Throws:
      IOException - when input stream unreadable