Package io.apicurio.registry.utils
Class IoUtil
java.lang.Object
io.apicurio.registry.utils.IoUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclose(AutoCloseable closeable) Close auto-closeable, unchecked IOException is thrown for any IO exception, IllegalStateException for all others.static voidcloseIgnore(AutoCloseable closeable) Close auto-closeable, ignore any exception.static longcopy(InputStream input, OutputStream output) static byte[]Get byte array from a file.static byte[]toBytes(InputStream stream) Get byte array from stream.static byte[]toBytes(InputStream stream, boolean closeStream) Get byte array from stream.static byte[]Get byte array from string.static InputStreamtoStream(byte[] content) static InputStreamGet stream from content.static StringtoString(byte[] bytes) Get string from byte array.static StringtoString(InputStream stream) Get string from stream.static voidunpackToDisk(ZipInputStream zip, Path outputDirectory) Writes the given zip file to an output directory (assumed to either not exist or be empty).
-
Constructor Details
-
IoUtil
public IoUtil()
-
-
Method Details
-
unpackToDisk
Writes the given zip file to an output directory (assumed to either not exist or be empty).- Parameters:
zip-outputDirectory-- Throws:
IOException
-
close
Close auto-closeable, unchecked IOException is thrown for any IO exception, IllegalStateException for all others.- Parameters:
closeable- the closeable
-
closeIgnore
Close auto-closeable, ignore any exception.- Parameters:
closeable- the closeable
-
toBytes
Get byte array from stream. Stream is closed at the end.- Parameters:
stream- the stream- Returns:
- stream as a byte array
-
toBytes
Get byte array from stream.- Parameters:
stream- the stream- Returns:
- stream as a byte array
-
toBytes
Get byte array from a file.- Parameters:
file- the file- Returns:
- file as a byte array
-
toString
Get string from stream. Stream is closed at the end.- Parameters:
stream- the stream- Returns:
- stream as a string
-
toString
Get string from byte array.- Parameters:
bytes- the bytes- Returns:
- byte array as a string
-
toBytes
Get byte array from string.- Parameters:
string- the string- Returns:
- string as byte array
-
toStream
Get stream from content.- Parameters:
content- the content- Returns:
- content as stream
-
toStream
-
copy
- Throws:
IOException
-