Java ByteBuffer from UTF bufferUTF(String string, ByteBuffer buffer)

Here you can find the source of bufferUTF(String string, ByteBuffer buffer)

Description

buffer UTF

License

Open Source License

Declaration

public static void bufferUTF(String string, ByteBuffer buffer) 

Method Source Code

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

import java.io.UnsupportedEncodingException;

import java.nio.ByteBuffer;

public class Main {
    public static void bufferUTF(String string, ByteBuffer buffer) {
        try {/*ww w .  j  av a 2  s  .  co  m*/
            byte[] bytes = string.getBytes("UTF-8");
            buffer.put(bytes);
            buffer.put((byte) 0);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. byteBufferFromUtf8String(final String data)