Here you can find the source of getStringDTrimmed(ByteBuffer byteBuffer, int length)
public static String getStringDTrimmed(ByteBuffer byteBuffer, int length)
//package com.java2s; /*//from w w w .j ava 2s . c om * 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 { public static String getStringDTrimmed(ByteBuffer byteBuffer, int length) { return getStringD(byteBuffer, length).trim(); } private static String getStringD(ByteBuffer byteBuffer, int length) { return getStringA(byteBuffer, length); } 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; } }