Java ByteBuffer Capacity parseToByteBuffer(int capacity, String value)

Here you can find the source of parseToByteBuffer(int capacity, String value)

Description

parse To Byte Buffer

License

Open Source License

Declaration

public static ByteBuffer parseToByteBuffer(int capacity, String value) 

Method Source Code


//package com.java2s;
/*//from   w  ww. j a va2  s . c o m
 mod_MumbleLink - Positional Audio Communication for Minecraft with Mumble
 Copyright 2011-2013 zsawyer (http://sourceforge.net/users/zsawyer)
    
 This file is part of mod_MumbleLink
 (http://sourceforge.net/projects/modmumblelink/).
    
 mod_MumbleLink is free software: you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
    
 mod_MumbleLink is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Lesser General Public License for more details.
    
 You should have received a copy of the GNU Lesser General Public License
 along with mod_MumbleLink.  If not, see <http://www.gnu.org/licenses/>.
    
 */

import java.nio.ByteBuffer;

public class Main {
    public static ByteBuffer parseToByteBuffer(int capacity, String value) {
        ByteBuffer buffer = ByteBuffer.allocate(capacity);
        buffer.rewind();
        buffer.put(value.getBytes());
        buffer.rewind();
        return buffer;
    }
}

Related

  1. growBuffer(ByteBuffer b, int newCapacity)
  2. increaseCapacity(ByteBuffer buffer, int size)
  3. leByteBuffer(int capacity)
  4. nativeByteBuffer(int capacity)
  5. newByteBuffer(int margin, int capacity)
  6. resetAddressAndCapacity(final ByteBuffer byteBuffer, final long address, final int capacity)