Java ByteBuffer Put putBytesUnescaped(ByteBuffer buffer, byte[] data)

Here you can find the source of putBytesUnescaped(ByteBuffer buffer, byte[] data)

Description

put Bytes Unescaped

License

Apache License

Declaration

public static void putBytesUnescaped(ByteBuffer buffer, byte[] data) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.nio.ByteBuffer;

public class Main {
    public static final byte ESCAPE_CHARACTER = 0x7D;

    public static void putBytesUnescaped(ByteBuffer buffer, byte[] data) {
        if (data.length > buffer.remaining()) {
            throw new IllegalArgumentException("Not enough room in the buffer for the data");
        }//from w w  w  .  j  av a 2 s .  c om
        for (int ix = 0; ix < data.length; ix++) {
            byte b = data[ix];
            if (b == ESCAPE_CHARACTER) {
                buffer.put((byte) (data[++ix] ^ 0x20));
            } else {
                buffer.put(b);
            }
        }
    }
}

Related

  1. putBoolean(ByteBuffer bb, boolean value)
  2. putByte(ByteBuffer byteBuffer, int value)
  3. putByteArray(ByteBuffer byteBuffer, byte[] array)
  4. putByteAsString(ByteBuffer buffer, byte value)
  5. putByteBuffer(ByteBuffer source, ByteBuffer target)
  6. putCharSequence(ByteBuffer buf, Charset charset, CharSequence value)
  7. putDecInt(ByteBuffer buffer, int n)
  8. putInt(ByteBuffer bb, long value)
  9. putInt(ByteBuffer buffer, int val, ByteOrder order)