Class IoUtil

java.lang.Object
io.apicurio.registry.utils.IoUtil

public class IoUtil extends Object
  • Constructor Details

    • IoUtil

      public IoUtil()
  • Method Details

    • unpackToDisk

      public static void unpackToDisk(ZipInputStream zip, Path outputDirectory) throws IOException
      Writes the given zip file to an output directory (assumed to either not exist or be empty).
      Parameters:
      zip -
      outputDirectory -
      Throws:
      IOException
    • close

      public static void close(AutoCloseable closeable)
      Close auto-closeable, unchecked IOException is thrown for any IO exception, IllegalStateException for all others.
      Parameters:
      closeable - the closeable
    • closeIgnore

      public static void closeIgnore(AutoCloseable closeable)
      Close auto-closeable, ignore any exception.
      Parameters:
      closeable - the closeable
    • toBytes

      public static byte[] toBytes(InputStream stream)
      Get byte array from stream. Stream is closed at the end.
      Parameters:
      stream - the stream
      Returns:
      stream as a byte array
    • toBytes

      public static byte[] toBytes(InputStream stream, boolean closeStream)
      Get byte array from stream.
      Parameters:
      stream - the stream
      Returns:
      stream as a byte array
    • toBytes

      public static byte[] toBytes(File file)
      Get byte array from a file.
      Parameters:
      file - the file
      Returns:
      file as a byte array
    • toString

      public static String toString(InputStream stream)
      Get string from stream. Stream is closed at the end.
      Parameters:
      stream - the stream
      Returns:
      stream as a string
    • toString

      public static String toString(byte[] bytes)
      Get string from byte array.
      Parameters:
      bytes - the bytes
      Returns:
      byte array as a string
    • toBytes

      public static byte[] toBytes(String string)
      Get byte array from string.
      Parameters:
      string - the string
      Returns:
      string as byte array
    • toStream

      public static InputStream toStream(String content)
      Get stream from content.
      Parameters:
      content - the content
      Returns:
      content as stream
    • toStream

      public static InputStream toStream(byte[] content)
    • copy

      public static long copy(InputStream input, OutputStream output) throws IOException
      Throws:
      IOException