websocket/src/main/java/org/nanohttpd/protocols/websockets/WebSocketFrame.java
public void write(OutputStream out) throws IOException {
        byte header = 0;
        if (this.fin) {
            header |= 0x80;
        }
        header |= this.opCode.getValue() & 0x0F;
        out.write(header);

        this._payloadLength = getBinaryPayload().length;
        if (this._payloadLength <= 125) {
            out.write(isMasked() ? 0x80 | (byte) this._payloadLength : (byte) this._payloadLength);
        } else if (this._payloadLength <= 0xFFFF) {
            out.write(isMasked() ? 0xFE : 126);
            out.write(this._payloadLength >>> 8);
            out.write(this._payloadLength);
        } else {
            out.write(isMasked() ? 0xFF : 127);
            out.write(this._payloadLength >>> 56 & 0); // integer only
                                                       // contains
            // 31 bit
            out.write(this._payloadLength >>> 48 & 0);
            out.write(this._payloadLength >>> 40 & 0);
            out.write(this._payloadLength >>> 32 & 0);
            out.write(this._payloadLength >>> 24);
            out.write(this._payloadLength >>> 16);
            out.write(this._payloadLength >>> 8);
            out.write(this._payloadLength);
        }

        if (isMasked()) {
            out.write(this.maskingKey);
            for (int i = 0; i < this._payloadLength; i++) {
                out.write(getBinaryPayload()[i] ^ this.maskingKey[i % 4]);
            }
        } else {
            out.write(getBinaryPayload());
        }
        out.flush();
    }
public void write(OutputStream out) throws IOException {
        byte header = 0;
        if (this.fin) {
            header |= 0x80;
        }
        header |= this.opCode.getValue() & 0x0F;
        out.write(header);

        this._payloadLength = getBinaryPayload().length;
        if (this._payloadLength <= 125) {
            out.write(isMasked() ? 0x80 | (byte) this._payloadLength : (byte) this._payloadLength);
        } else if (this._payloadLength <= 0xFFFF) {
            out.write(isMasked() ? 0xFE : 126);
            out.write(this._payloadLength >>> 8);
            out.write(this._payloadLength);
        } else {
            out.write(isMasked() ? 0xFF : 127);
            out.write(this._payloadLength >>> 56 & 0); // integer only
                                                       // contains
            // 31 bit
            out.write(this._payloadLength >>> 48 & 0);
            out.write(this._payloadLength >>> 40 & 0);
            out.write(this._payloadLength >>> 32 & 0);
            out.write(this._payloadLength >>> 24);
            out.write(this._payloadLength >>> 16);
            out.write(this._payloadLength >>> 8);
            out.write(this._payloadLength);
        }

        if (isMasked()) {
            out.write(this.maskingKey);
            for (int i = 0; i < this._payloadLength; i++) {
                out.write(getBinaryPayload()[i] ^ this.maskingKey[i % 4]);
            }
        } else {
            out.write(getBinaryPayload());
        }
        out.flush();
    }
public void write ( OutputStream out ) throws IOException { byte header = 0 ; if ( this . fin ) { header |= 0x80 ; } header |= this . opCode . getValue ( ) & 0x0F ; out . write ( header ) ; this . _payloadLength = getBinaryPayload ( ) . length ; if ( this . _payloadLength <= 125 ) { out . write ( isMasked ( ) ? 0x80 | ( byte ) this . _payloadLength : ( byte ) this . _payloadLength ) ; } else if ( this . _payloadLength <= 0xFFFF ) { out . write ( isMasked ( ) ? 0xFE : 126 ) ; out . write ( this . _payloadLength >>> 8 ) ; out . write ( this . _payloadLength ) ; } else { out . write ( isMasked ( ) ? 0xFF : 127 ) ; out . write ( this . _payloadLength >>> 56 & 0 ) ; // integer only // contains // 31 bit out . write ( this . _payloadLength >>> 48 & 0 ) ; out . write ( this . _payloadLength >>> 40 & 0 ) ; out . write ( this . _payloadLength >>> 32 & 0 ) ; out . write ( this . _payloadLength >>> 24 ) ; out . write ( this . _payloadLength >>> 16 ) ; out . write ( this . _payloadLength >>> 8 ) ; out . write ( this . _payloadLength ) ; } if ( isMasked ( ) ) { out . write ( this . maskingKey ) ; for ( int i = 0 ; i < this . _payloadLength ; i ++ ) { out . write ( getBinaryPayload ( ) [ i ] ^ this . maskingKey [ i % 4 ] ) ; } } else { out . write ( getBinaryPayload ( ) ) ; } out . flush ( ) ; }
------------------------------------------------------------------------
------------------------------------------------------------------------