Class CameoUtilities

java.lang.Object
com.nomagic.utils.CameoUtilities
Direct Known Subclasses:
Utilities

@OpenApiAll public class CameoUtilities extends Object
General purpose utilities.
  • Constructor Details

    • CameoUtilities

      public CameoUtilities()
  • Method Details

    • isEqual

      public static boolean isEqual(@CheckForNull Object obj1, @CheckForNull 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 Object[] obj1, @CheckForNull Object[] obj2)
      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

      public static String replaceNewLine(String string, String lineSeparator)
      Separate lines with the provided separator string.
      Parameters:
      string - input string.
      lineSeparator - line separator.
      Returns:
      result string.
    • copy

      public static void copy(Reader input, Writer output) throws IOException
      Copies all bytes from Reader into Writer. Closes the reader and writer.
      Parameters:
      input - the reader.
      output - the writer.
      Throws:
      IOException
    • copy

      public static void copy(InputStream input, OutputStream output) throws IOException
      Throws:
      IOException
    • toByteArray

      public static byte[] toByteArray(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(String bytes)
      Returns byte array from string formatted in toString(byte[]) method.
      Parameters:
      bytes - the given string.
      Returns:
      the byte array.
    • toString

      public static 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 String removeFromLine(String line, 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(String name, List<String> extensions)
      Checks if given file name has one of given file extensions.
    • hasExtension

      public static boolean hasExtension(String name, String extension)
      Checks if given file name has given file extension.
    • removeExtension

      public static String removeExtension(String name, Collection<String> extensions)
      Removes file extension form given file name.