Here you can find the source of bytesToStringUTFCustom(byte[] bytes)
Use during externalization methods....FAST as it avoids charset encoding From http://www.javacodegeeks.com/2010/11/java-best-practices-char-to-byte-and.html
Parameter | Description |
---|---|
str | a parameter |
public static String bytesToStringUTFCustom(byte[] bytes)
//package com.java2s; //License from project: Apache License public class Main { /**//from www .j a v a 2s . c o m * Use during externalization methods....FAST as it avoids charset encoding * From http://www.javacodegeeks.com/2010/11/java-best-practices-char-to-byte-and.html * @param str * @return */ public static String bytesToStringUTFCustom(byte[] bytes) { char[] buffer = new char[bytes.length >> 1]; for (int i = 0; i < buffer.length; i++) { int bpos = i << 1; char c = (char) (((bytes[bpos] & 0x00FF) << 8) + (bytes[bpos + 1] & 0x00FF)); buffer[i] = c; } return new String(buffer); } }