public static void writeBytes(OutputStream os,byte[] buf) throws IOException {
  if (buf.length < OP_PUSHDATA1) {
    os.write(buf.length);
    os.write(buf);
  }
 else   if (buf.length < 256) {
    os.write(OP_PUSHDATA1);
    os.write(buf.length);
    os.write(buf);
  }
 else   if (buf.length < 65536) {
    os.write(OP_PUSHDATA2);
    os.write(0xFF & (buf.length));
    os.write(0xFF & (buf.length >> 8));
    os.write(buf);
  }
 else {
    throw new RuntimeException("Unimplemented");
  }
}

public static void writeBytes ( OutputStream os , byte [ ] buf ) throws IOException { if ( buf . length < OP_PUSHDATA1 ) { os . write ( buf . length ) ; os . write ( buf ) ; } else if ( buf . length < 256 ) { os . write ( OP_PUSHDATA1 ) ; os . write ( buf . length ) ; os . write ( buf ) ; } else if ( buf . length < 65536 ) { os . write ( OP_PUSHDATA2 ) ; os . write ( 0xFF & ( buf . length ) ) ; os . write ( 0xFF & ( buf . length > > 8 ) ) ; os . write ( buf ) ; } else { throw new RuntimeException ( "Unimplemented" ) ; } }
writes out the given byte buffer to the output stream with the correct opcode prefix to write an integer call writebytes ( out , utils . reversebytes ( utils . encodempi ( val , false ) ) ) ;
