code: public void encode(DerOutputStream out)
      throws IOException {
          out.write(tag);
          out.putLength(length);
          // XXX yeech, excess copies ... DerInputBuffer.write(OutStream)
          if (length > 0) {
              byte[] value = new byte[length];
              // always synchronized on data
              synchronized (data) {
                  buffer.reset();
                  if (buffer.read(value) != length) {
                      throw new IOException("short DER value read (encode)");
                  }
                  out.write(value);
              }
          }
      }
docs: Encode an ASN1/DER encoded datum onto a DER output stream.