class IoUtils {

  public static int redirect(final InputStream from, final OutputStream to) throws IOException {
    assertNotNull(to);
    try {
      return stream(from, new StreamConsumer() {
        @Override
        public void apply(byte[] bytes, int offset, int length) throws Exception {
          to.write(bytes, offset, length);
        }
      });
    } catch (final Exception e) {
      throw (IOException) e;
    }
  }

}