Package fr.gouv.vitam.common
Class StringUtils
java.lang.Object
fr.gouv.vitam.common.StringUtils
String utils
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcheckSanityString(String value) Check external argument to avoid Path Traversal attackstatic voidcheckSanityString(String... strings) Check external argumentstatic final byte[]getBytesFromArraysToString(String bytesString) Revert Arrays.toString for bytesstatic final StringgetClassName(Object object) static final byte[]getRandom(int length) static StringGet text content of an input streamstatic final StringsubstringBeforeLast(String source, String separator) Gets the substring before the last occurrence of a separator.static final StringsubstringBetween(String source, String start, String end) Gets the String that is nested in between two Strings.
-
Field Details
-
HTML_PATTERN
-
UNPRINTABLE_PATTERN
-
RULES
-
-
Method Details
-
checkSanityString
Check external argument to avoid Path Traversal attack- Parameters:
value- to check- Throws:
InvalidParseOperationException
-
checkSanityString
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
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
- Parameters:
object- to get its class name- Returns:
- the short name of the Class of this object
-
substringBetween
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
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
Get text content of an input stream- Parameters:
is- input stream- Returns:
- text content
- Throws:
IOException- when input stream unreadable
-