Package com.nomagic.utils
Class CameoUtilities
- java.lang.Object
-
- com.nomagic.utils.CameoUtilities
-
- Direct Known Subclasses:
Utilities
@OpenApiAll public class CameoUtilities extends java.lang.Object
General purpose utilities.
-
-
Constructor Summary
Constructors Constructor Description CameoUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
copy(java.io.InputStream input, java.io.OutputStream output)
static void
copy(java.io.Reader input, java.io.Writer output)
Copies all bytes from Reader into Writer.static boolean
hasExtension(java.lang.String name, java.lang.String extension)
Checks if given file name has given file extension.static boolean
hasExtension(java.lang.String name, java.util.List extensions)
Checks if given file name has one of given file extensions.static boolean
isEqual(java.lang.Object[] obj1, java.lang.Object[] obj2)
Returns true of both objects are nulls or equalstatic boolean
isEqual(java.lang.Object obj1, java.lang.Object obj2)
Returns true of both objects are nulls or equalstatic java.lang.String
removeExtension(java.lang.String name, java.util.Collection<java.lang.String> extensions)
Removes file extension form given file name.static java.lang.String
removeFromLine(java.lang.String line, java.lang.String trash)
Removes from line trash linestatic java.lang.String
replaceNewLine(java.lang.String string, java.lang.String lineSeparator)
Separate lines with the provided separator string.static byte[]
toByteArray(java.io.InputStream stream)
Copies the given file into the array of bytes.static byte[]
toByteArray(java.lang.String bytes)
Returns byte array from string formatted in toString(byte[]) method.static java.lang.String
toString(byte[] data)
Returns string representation of the given byte array.static java.lang.String
toString(java.io.InputStream inputStream, java.lang.String encoding)
Get String representation of inputStream
-
-
-
Method Detail
-
isEqual
public static boolean isEqual(@CheckForNull java.lang.Object obj1, @CheckForNull java.lang.Object obj2)
Returns true of both objects are nulls or equal- Parameters:
obj1
- First object.obj2
- Second object.- Returns:
- boolean
-
isEqual
public static boolean isEqual(@CheckForNull java.lang.Object[] obj1, @CheckForNull java.lang.Object[] obj2)
Returns true of both objects are nulls or equal- Parameters:
obj1
- object list.obj2
- object list.- Returns:
- boolean
-
toString
public static java.lang.String toString(java.io.InputStream inputStream, @CheckForNull java.lang.String encoding) throws java.io.IOException
Get String representation of inputStream- Parameters:
inputStream
- The given inputStream- Returns:
- String representation
- Throws:
java.io.IOException
-
replaceNewLine
public static java.lang.String replaceNewLine(java.lang.String string, java.lang.String lineSeparator)
Separate lines with the provided separator string.- Parameters:
string
- input string.lineSeparator
- line separator.- Returns:
- result string.
-
copy
public static void copy(java.io.Reader input, java.io.Writer output) throws java.io.IOException
Copies all bytes from Reader into Writer. Closes the reader and writer.- Parameters:
input
- the reader.output
- the writer.- Throws:
java.io.IOException
-
copy
public static void copy(java.io.InputStream input, java.io.OutputStream output) throws java.io.IOException
- Throws:
java.io.IOException
-
toByteArray
public static byte[] toByteArray(java.io.InputStream stream)
Copies the given file into the array of bytes.- Parameters:
stream
- the given file.- Returns:
- the byte array with the context of the file;null if some errors occurs
-
toByteArray
public static byte[] toByteArray(java.lang.String bytes)
Returns byte array from string formatted in toString(byte[]) method.- Parameters:
bytes
- the given string.- Returns:
- the byte array.
-
toString
public static java.lang.String toString(byte[] data)
Returns string representation of the given byte array.- Parameters:
data
- the given bytes array.- Returns:
- the string representation (every byte is represented as hex string separated by space)
-
removeFromLine
public static java.lang.String removeFromLine(java.lang.String line, java.lang.String trash)
Removes from line trash line- Parameters:
line
- the given line.trash
- characters as string.- Returns:
- The given string without From Line.
-
hasExtension
public static boolean hasExtension(java.lang.String name, java.util.List extensions)
Checks if given file name has one of given file extensions.
-
hasExtension
public static boolean hasExtension(java.lang.String name, java.lang.String extension)
Checks if given file name has given file extension.
-
removeExtension
public static java.lang.String removeExtension(java.lang.String name, java.util.Collection<java.lang.String> extensions)
Removes file extension form given file name.
-
-