// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
//   if (reference != null) {
//     return reference;
//   } else {
//     throw new NullPointerException();
//   }
// }


import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
      if (r == -1) {
        break;
      }
      to.write(buf, 0, r);
      total += r;
    }
    return total;
  }

  static byte[] toByteArray(InputStream in) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    copy(in, out);
    return out.toByteArray();
  }

  public static byte[] readFully(InputStream in, byte[] bytes) throws IOException {
    return readFully(in, bytes, 0, bytes.length);
  }

  public static byte[] readFully(InputStream in, byte[] bytes, int off, int len) throws IOException {
    int read = read(in, bytes, off, len);
    if (read != len) {
      String message = String.format("reached end of stream after reading %d bytes; %d bytes expected", read, len);
      throw new EOFException(message);
    }
    return bytes;
  }

  public static int read(InputStream in, byte[] bytes, int off, int len)
      throws IOException {
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
//   if (reference != null) {
//     return reference;
//   } else {
//     throw new NullPointerException();
//   }
// }


// Path: src/main/java/be/fror/common/io/ByteStreams.java
import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

      if (r == -1) {
        break;
      }
      to.write(buf, 0, r);
      total += r;
    }
    return total;
  }

  static byte[] toByteArray(InputStream in) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    copy(in, out);
    return out.toByteArray();
  }

  public static byte[] readFully(InputStream in, byte[] bytes) throws IOException {
    return readFully(in, bytes, 0, bytes.length);
  }

  public static byte[] readFully(InputStream in, byte[] bytes, int off, int len) throws IOException {
    int read = read(in, bytes, off, len);
    if (read != len) {
      String message = String.format("reached end of stream after reading %d bytes; %d bytes expected", read, len);
      throw new EOFException(message);
    }
    return bytes;
  }

  public static int read(InputStream in, byte[] bytes, int off, int len)
      throws IOException {
    checkNotNull(in);