Here you can find the source of getMultiString(ByteBuffer bb, boolean wideChar)
public static String[] getMultiString(ByteBuffer bb, boolean wideChar)
//package com.java2s; /******************************************************************************* * This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * //w w w .j a v a 2 s . co m * Contributors: * Peter Smith *******************************************************************************/ import java.nio.ByteBuffer; import java.util.ArrayList; public class Main { public static String[] getMultiString(ByteBuffer bb, boolean wideChar) { ArrayList strs = new ArrayList(); StringBuilder sb = new StringBuilder(); while (bb.hasRemaining()) { char c = wideChar ? bb.getChar() : (char) bb.get(); if (c == 0) { if (sb.length() == 0) { break; } else { strs.add(sb.toString()); sb.setLength(0); } } else { sb.append(c); } } return (String[]) strs.toArray(new String[strs.size()]); } }