Java ByteBuffer from getByteBufferFromUTF8(String str)

Here you can find the source of getByteBufferFromUTF8(String str)

Description

get Byte Buffer From UTF

License

Open Source License

Declaration

public static ByteBuffer getByteBufferFromUTF8(String str) 

Method Source Code

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

import java.nio.*;
import java.nio.charset.*;

public class Main {
    public static ByteBuffer getByteBufferFromUTF8(String str) {
        Charset charset = Charset.forName("UTF-8");
        CharsetEncoder encoder = charset.newEncoder();
        try {/*from  w  ww.j a  v  a2 s  .  c o m*/
            return encoder.encode(CharBuffer.wrap(str));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. getByteBufferAsString(ByteBuffer buff)
  2. getByteBufferByString(String message)
  3. getByteBufferFromBytes(byte[] data)
  4. getByteBufferFromInt(int value)
  5. getByteBufferFromList(List values)
  6. getByteBufferFromUUID(java.util.UUID uuid)
  7. getByteBufferOutputStream(final ByteBuffer buf)
  8. getByteBufferReadMethod(Class clazz)
  9. getByteBuffers(Collection newValue)

  10. HOME | Copyright © www.java2s.com 2016