code: public static void transfer(final InputStream istream, final OutputStream ostream, final boolean close) {
          try {
              final byte[] bytes = new byte[2_048];
              int read;
              while ((read = istream.read(bytes)) != -1) {
                  ostream.write(bytes, 0, read);
              }
          } catch (IOException e) {
              throw new TransportingException(e);
          } finally {
              if (close) {
                  try {
                      ostream.close();
                  } catch (IOException ioe) {
                      throw new TransportingException(ioe);
                  }
              }
          }
      }
docs: Transfers the contents of the {@link InputStream} into the {@link OutputStream}, optionally closing the stream.
  
  @param istream the input stream
  @param ostream the output stream
  @param close   whether or not to close the output stream