Here you can find the source of stringsFromBinary(final byte[] binary)
Parameter | Description |
---|---|
binary | a byte array to convert to a String |
public static String[] stringsFromBinary(final byte[] binary)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; import java.nio.charset.Charset; public class Main { public static final Charset GEOWAVE_CHAR_SET = Charset.forName("ISO-8859-1"); /**/*from w w w . ja va2 s .com*/ * Utility to convert bytes to a String * * @param binary * a byte array to convert to a String * @return a String representation of the byte array */ public static String[] stringsFromBinary(final byte[] binary) { final ByteBuffer buf = ByteBuffer.wrap(binary); final int count = buf.getInt(); final String[] result = new String[count]; for (int i = 0; i < count; i++) { final int size = buf.getInt(); final byte[] strBytes = new byte[size]; buf.get(strBytes); result[i] = new String(strBytes, GEOWAVE_CHAR_SET); } return result; } }