Java ByteBuffer Set setString(ByteBuffer buffer, String data)

Here you can find the source of setString(ByteBuffer buffer, String data)

Description

set String

License

Open Source License

Declaration

public static void setString(ByteBuffer buffer, String data) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Array;
import java.nio.ByteBuffer;

public class Main {
    public static void setString(ByteBuffer buffer, String data) {

        assert (null != data);

        byte[] bytes = data.getBytes();
        assert (buffer.capacity() - buffer.position() >= Array.getLength(bytes));

        buffer.put(bytes);/*from  www  .j ava 2s  . c  om*/
        buffer.put((byte) 0);
    }
}

Related

  1. setLimIfNeeded(ByteBuffer bb, int lim)
  2. setLong(ByteBuffer buffer, long data)
  3. setSByte(ByteBuffer buffer, byte data)
  4. setSInt(ByteBuffer buffer, int data)
  5. setString(ByteBuffer buffer, int index)
  6. setUniqueness(ByteBuffer bb, long uniqueness)
  7. setUnsignedInt32(ByteBuffer buffer, int offset, long value)
  8. setZipEocdCentralDirectoryOffset(ByteBuffer zipEndOfCentralDirectory, long offset)
  9. subsequence(ByteBuffer[] bs, int offset, int length)