Java ByteBuffer Put putByteAsString(ByteBuffer buffer, byte value)

Here you can find the source of putByteAsString(ByteBuffer buffer, byte value)

Description

Writes a single byte as raw characer data into the specified buffer.

License

Apache License

Parameter

Parameter Description
buffer The byte buffer to write to.
value The value to write.

Return

The byte buffer with the value written to it. This may be a different buffer to the one passed in if the buffer had to be copied in order to increase its size.

Declaration

public static ByteBuffer putByteAsString(ByteBuffer buffer, byte value) 

Method Source Code


//package com.java2s;
/*//from  ww  w  . j av  a  2  s .c  o  m
 * Copyright The Sett Ltd, 2005 to 2014.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.nio.ByteBuffer;

public class Main {
    /**
     * Writes a single byte as raw characer data into the specified buffer. The buffer is increased in size using the
     * supplied buffer pool, if needed.
     *
     * @param  buffer The byte buffer to write to.
     * @param  value  The value to write.
     *
     * @return The byte buffer with the value written to it. This may be a different buffer to the one passed in if the
     *         buffer had to be copied in order to increase its size.
     */
    public static ByteBuffer putByteAsString(ByteBuffer buffer, byte value) {
        buffer.put(value);

        return buffer;
    }
}

Related

  1. putAscii(ByteBuffer bytes, String value)
  2. putAsMuchAsPossible(ByteBuffer dest, ByteBuffer src)
  3. putBoolean(ByteBuffer bb, boolean value)
  4. putByte(ByteBuffer byteBuffer, int value)
  5. putByteArray(ByteBuffer byteBuffer, byte[] array)
  6. putByteBuffer(ByteBuffer source, ByteBuffer target)
  7. putBytesUnescaped(ByteBuffer buffer, byte[] data)
  8. putCharSequence(ByteBuffer buf, Charset charset, CharSequence value)
  9. putDecInt(ByteBuffer buffer, int n)