Here you can find the source of getString(java.nio.ByteBuffer buffer, int offset, int len)
public static String getString(java.nio.ByteBuffer buffer, int offset, int len)
//package com.java2s; public class Main { public static String getString(java.nio.ByteBuffer buffer, int offset, int len) { String s = ""; if (null != buffer && buffer.capacity() >= offset + len) { byte[] dest = new byte[len]; buffer.position(offset);/*from w w w . ja va 2s . c o m*/ buffer.get(dest, 0, len); s = new String(dest).trim(); } return s; } public static String getString(java.nio.ByteBuffer buffer, int len) { String s = ""; if (null != buffer && buffer.remaining() >= len) { byte[] dest = new byte[len]; buffer.get(dest, 0, len); s = new String(dest).trim(); } return s; } }