Package fr.gouv.vitam.common
Class StringUtils
- java.lang.Object
-
- fr.gouv.vitam.common.StringUtils
-
public final class StringUtils extends java.lang.ObjectString utils
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.PatternHTML_PATTERNstatic java.util.List<java.lang.String>RULESstatic java.util.regex.PatternUNPRINTABLE_PATTERN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringcheckSanityString(java.lang.String value)Check external argument to avoid Path Traversal attackstatic voidcheckSanityString(java.lang.String... strings)Check external argumentstatic byte[]getBytesFromArraysToString(java.lang.String bytesString)Revert Arrays.toString for bytesstatic java.lang.StringgetClassName(java.lang.Object object)static byte[]getRandom(int length)static java.lang.StringgetStringFromInputStream(java.io.InputStream is)Get text content of an input streamstatic java.lang.StringsubstringBeforeLast(java.lang.String source, java.lang.String separator)Gets the substring before the last occurrence of a separator.static java.lang.StringsubstringBetween(java.lang.String source, java.lang.String start, java.lang.String end)Gets the String that is nested in between two Strings.
-
-
-
Method Detail
-
checkSanityString
public static java.lang.String checkSanityString(java.lang.String value) throws InvalidParseOperationExceptionCheck external argument to avoid Path Traversal attack- Parameters:
value- to check- Throws:
InvalidParseOperationException
-
checkSanityString
public static void checkSanityString(java.lang.String... strings) throws InvalidParseOperationExceptionCheck 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(java.lang.String bytesString)
Revert Arrays.toString for bytes- Parameters:
bytesString- the string to transform- Returns:
- the array of bytes
- Throws:
java.lang.IllegalArgumentException- if bytesString is null or empty
-
getClassName
public static final java.lang.String getClassName(java.lang.Object object)
- Parameters:
object- to get its class name- Returns:
- the short name of the Class of this object
-
substringBetween
public static final java.lang.String substringBetween(java.lang.String source, java.lang.String start, java.lang.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 java.lang.String substringBeforeLast(java.lang.String source, java.lang.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 java.lang.String getStringFromInputStream(java.io.InputStream is) throws java.io.IOExceptionGet text content of an input stream- Parameters:
is- input stream- Returns:
- text content
- Throws:
java.io.IOException- when input stream unreadable
-
-