// Path: common/src/main/java/eu/mikroskeem/shuriken/common/SneakyThrow.java
// public class SneakyThrow {
//     /**
//      * Good old SneakyThrows! Throws checked exceptions everywhere you want
//      *
//      * @param t Throwable
//      */
//     @Contract("_ -> fail")
//     public static void throwException(Throwable t) {
//         throw SneakyThrow.<RuntimeException>_throwException(t);
//     }
// 
//     @Contract("_ -> fail")
//     @SuppressWarnings("unchecked")
//     private static <T extends Throwable> T _throwException(Throwable t) throws T {
//         throw (T) Ensure.notNull(t, "Throwable should not be null");
//     }
// }
// 
// Path: common/src/main/java/eu/mikroskeem/shuriken/common/Ensure.java
// @Contract("null, _ -> fail; !null, _ -> !null")
// public static <T> T notNull(T ref, @Nullable String errorMessage) {
//     ensureCondition(ref != null, NullPointerException.class, of(""+errorMessage));
//     return ref;
// }


import eu.mikroskeem.shuriken.common.SneakyThrow;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import static eu.mikroskeem.shuriken.common.Ensure.notNull;
package eu.mikroskeem.shuriken.common.streams;




/**
 * Bytearray tools
 *
 * @author Mark Vainomaa
 * @version 0.0.1
 */
public class ByteArrays {
    /**
     * Convert an {@link InputStream} to byte array
     *
     * @param inputStream Source {@link InputStream}
     * @return byte array or null, if reading failed
     */
    @Nullable
    @Contract("null -> fail; !null -> !null")
    public static byte[] fromInputStream(InputStream inputStream) {
        notNull(inputStream, "Input stream must not be null!");
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        try {
            byte[] buffer = new byte[1024];
            int length;
            while ((length =inputStream.read(buffer)) != -1)
                output.write(buffer, 0, length);
            return output.toByteArray();
        } catch (IOException e){
// Path: common/src/main/java/eu/mikroskeem/shuriken/common/SneakyThrow.java
// public class SneakyThrow {
//     /**
//      * Good old SneakyThrows! Throws checked exceptions everywhere you want
//      *
//      * @param t Throwable
//      */
//     @Contract("_ -> fail")
//     public static void throwException(Throwable t) {
//         throw SneakyThrow.<RuntimeException>_throwException(t);
//     }
// 
//     @Contract("_ -> fail")
//     @SuppressWarnings("unchecked")
//     private static <T extends Throwable> T _throwException(Throwable t) throws T {
//         throw (T) Ensure.notNull(t, "Throwable should not be null");
//     }
// }
// 
// Path: common/src/main/java/eu/mikroskeem/shuriken/common/Ensure.java
// @Contract("null, _ -> fail; !null, _ -> !null")
// public static <T> T notNull(T ref, @Nullable String errorMessage) {
//     ensureCondition(ref != null, NullPointerException.class, of(""+errorMessage));
//     return ref;
// }


// Path: common/src/main/java/eu/mikroskeem/shuriken/common/streams/ByteArrays.java
import eu.mikroskeem.shuriken.common.SneakyThrow;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import static eu.mikroskeem.shuriken.common.Ensure.notNull;

package eu.mikroskeem.shuriken.common.streams;




/**
 * Bytearray tools
 *
 * @author Mark Vainomaa
 * @version 0.0.1
 */
public class ByteArrays {
    /**
     * Convert an {@link InputStream} to byte array
     *
     * @param inputStream Source {@link InputStream}
     * @return byte array or null, if reading failed
     */
    @Nullable
    @Contract("null -> fail; !null -> !null")
    public static byte[] fromInputStream(InputStream inputStream) {
        notNull(inputStream, "Input stream must not be null!");
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        try {
            byte[] buffer = new byte[1024];
            int length;
            while ((length =inputStream.read(buffer)) != -1)
                output.write(buffer, 0, length);
            return output.toByteArray();
        } catch (IOException e){
            SneakyThrow.throwException(e);