Class Util

java.lang.Object
org.faceless.publisher.type.Util

public class Util extends Object
A collection of static Utility methods
  • Field Details

  • Method Details

    • hex

      public static byte[] hex(String in)
      Return a byte array from the hex-encoded input
    • hex

      public static String hex(byte[] in)
      Return the byte array as a lowercase hex string
    • equals

      public static boolean equals(Object o1, Object o2)
    • toString

      public static String toString(Object o)
      A toString() method that improves on the original where possible
      Parameters:
      o - the object to convert to a String
    • readFully

      public static byte[] readFully(InputStream in) throws IOException
      Convenient method to read an InputStream fully into a byte array.
      Parameters:
      in - the InputStream The stream is closed on completion
      Throws:
      IOException
    • copyStream

      public static void copyStream(InputStream in, OutputStream out) throws IOException
      Convenient method to copy an InputStream to an OutputStream.
      Parameters:
      in - the InputStream
      out - the OutputStream
      Throws:
      IOException
    • createDataURL

      public static URL2 createDataURL(MediaType mediaType, String data)
      Create a "data:" URL
      Parameters:
      mediaType - the mediaType to specify, or null to leave this unset
      data - the data to encode. The result will not be Base-64 encoded
      Returns:
      the data URL
    • createDataURL

      public static URL2 createDataURL(MediaType mediaType, InputStream in) throws IOException
      Create a "data:" URL which will be Base-64 encoded.
      Parameters:
      mediaType - the mediaType to specify, or null to leave this unset
      in - the InputStream to read the data to encode. The stream is not closed
      Returns:
      the data URL
      Throws:
      IOException
    • createDataURL

      public static URL2 createDataURL(Blob blob)
      Create a "data:" URL from the specified Blob
      Parameters:
      blob - the blob to convert
      Returns:
      the data URL
    • getCompressingOutputStream

      public static OutputStream getCompressingOutputStream(OutputStream out, String type) throws IOException
      Compress the supplied OutputStream
      Parameters:
      type - the algorithm - lz4, gzip, zstd, xz, or null for no compression
      Throws:
      IOException