Package com.nomagic.utils
Class CameoUtilities
java.lang.Object
com.nomagic.utils.CameoUtilities
- Direct Known Subclasses:
Utilities
General purpose utilities.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
copy
(InputStream input, OutputStream output) static void
Copies all bytes from Reader into Writer.static boolean
hasExtension
(String name, String extension) Checks if given file name has given file extension.static boolean
hasExtension
(String name, List<String> extensions) Checks if given file name has one of given file extensions.static boolean
Returns true of both objects are nulls or equalstatic boolean
Returns true of both objects are nulls or equalstatic String
removeExtension
(String name, Collection<String> extensions) Removes file extension form given file name.static String
removeFromLine
(String line, String trash) Removes from line trash linestatic String
replaceNewLine
(String string, String lineSeparator) Separate lines with the provided separator string.static byte[]
toByteArray
(InputStream stream) Copies the given file into the array of bytes.static byte[]
toByteArray
(String bytes) Returns byte array from string formatted in toString(byte[]) method.static String
toString
(byte[] data) Returns string representation of the given byte array.static String
toString
(InputStream inputStream, String encoding) Get String representation of inputStream
-
Constructor Details
-
CameoUtilities
public CameoUtilities()
-
-
Method Details
-
isEqual
Returns true of both objects are nulls or equal- Parameters:
obj1
- First object.obj2
- Second object.- Returns:
- boolean
-
isEqual
Returns true of both objects are nulls or equal- Parameters:
obj1
- object list.obj2
- object list.- Returns:
- boolean
-
toString
public static String toString(InputStream inputStream, @CheckForNull String encoding) throws IOException Get String representation of inputStream- Parameters:
inputStream
- The given inputStream- Returns:
- String representation
- Throws:
IOException
-
replaceNewLine
Separate lines with the provided separator string.- Parameters:
string
- input string.lineSeparator
- line separator.- Returns:
- result string.
-
copy
Copies all bytes from Reader into Writer. Closes the reader and writer.- Parameters:
input
- the reader.output
- the writer.- Throws:
IOException
-
copy
- Throws:
IOException
-
toByteArray
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
Returns byte array from string formatted in toString(byte[]) method.- Parameters:
bytes
- the given string.- Returns:
- the byte array.
-
toString
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
Removes from line trash line- Parameters:
line
- the given line.trash
- characters as string.- Returns:
- The given string without From Line.
-
hasExtension
Checks if given file name has one of given file extensions. -
hasExtension
Checks if given file name has given file extension. -
removeExtension
Removes file extension form given file name.
-