Java ByteBuffer to String getStringA(ByteBuffer byteBuffer, int length)

Here you can find the source of getStringA(ByteBuffer byteBuffer, int length)

Description

get String A

License

CDDL license

Declaration

private static String getStringA(ByteBuffer byteBuffer, int length) 

Method Source Code


//package com.java2s;
/*//  w w w .j  ava  2s . c o  m
 *         COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Notice
 *
 * The contents of this file are subject to the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.opensource.org/licenses/cddl1.txt
 *
 * The Original Code is Drombler.org. The Initial Developer of the
 * Original Code is Florian Brunner (Sourceforge.net user: puce).
 * Copyright 2014 Drombler.org. All Rights Reserved.
 *
 * Contributor(s): .
 */

import java.nio.ByteBuffer;

public class Main {
    private static String getStringA(ByteBuffer byteBuffer, int length) {
        byte[] dst = getBytes(byteBuffer, length);
        return new String(dst);
    }

    private static byte[] getBytes(ByteBuffer byteBuffer, int length) {
        byte[] dst = new byte[length];
        byteBuffer.get(dst);
        return dst;
    }
}

Related

  1. getString(ByteBuffer byteBuffer, int size)
  2. getString(ByteBuffer in, int maxLength)
  3. getString(final ByteBuffer buffer)
  4. getString(final ByteBuffer buffer, final int offset, final int length, final Charset encoding)
  5. getString(java.nio.ByteBuffer buffer, int offset, int len)
  6. getStringDTrimmed(ByteBuffer byteBuffer, int length)
  7. getStringFromBuffer(ByteBuffer buf, int len)
  8. getStringFromBuffer(ByteBuffer buffer, int length)
  9. getStringFromByteBuffer(ByteBuffer bb)