List of utility methods to do Byte Array to String by Charset
String | convertToString(byte[] bytes, Charset charset) convert To String String ret = new String(bytes, charset); if ((bytes[0] == 0xEF - 256) && (bytes[1] == 0xBB - 256) && (bytes[2] == 0xBF - 256)) { ret = ret.substring(1); } else if ((bytes[0] == 0xFE - 256) && (bytes[1] == 0xFF - 256)) { ret = ret.substring(1); } else if ((bytes[0] == 0xFF - 256) && (bytes[1] == 0xFE - 256)) { ret = ret.substring(1); return ret; |
String | convertToString(final byte[] bytes, final Charset charset) convert To String return new String(bytes, charset); |
String | decode(CharsetDecoder decoder, byte[] in) decode ByteBuffer inBuf = ByteBuffer.wrap(in);
CharBuffer outBuf = CharBuffer.allocate(inBuf.capacity() * Math.round(decoder.maxCharsPerByte() + 0.5f));
decoder.decode(inBuf, outBuf, true);
decoder.flush(outBuf);
decoder.reset();
return outBuf.flip().toString();
|
String | decode(final byte[] binaryValue, final Charset charset) decode final CharsetDecoder decoder = charset.newDecoder(); try { final ByteBuffer bbuf = ByteBuffer.wrap(binaryValue); final CharBuffer cbuf = decoder.decode(bbuf); return cbuf.toString(); } catch (final CharacterCodingException e) { return null; |
String | decode(final byte[] binaryValue, final Charset charset) decode final CharsetDecoder decoder = charset.newDecoder(); try { final ByteBuffer bbuf = ByteBuffer.wrap(binaryValue); final CharBuffer cbuf = decoder.decode(bbuf); return cbuf.toString(); } catch (final CharacterCodingException e) { return null; |
String | decode(final byte[] pData, final int pOffset, final int pLength, final String pCharset) Constructs a new String by decoding the specified sub array of bytes using the specified charset. try { return new String(pData, pOffset, pLength, pCharset); } catch (UnsupportedEncodingException e) { throw new UnsupportedCharsetException(pCharset); |
CharBuffer | decodeBytes(byte[] data, Charset charset, boolean report) decode Bytes CodingErrorAction action = (report) ? CodingErrorAction.REPORT : CodingErrorAction.REPLACE;
CharsetDecoder decoder = charset.newDecoder();
decoder.onMalformedInput(action);
decoder.onUnmappableCharacter(action);
return decoder.decode(ByteBuffer.wrap(data));
|
String | decodeCHARSET(byte[] bytes, Charset charset) Decodifica un arreglo de bytes para un juego de caracteres return new String(bytes, charset); |
CharBuffer | decodeHelper(byte[] byteArray, int numberOfBytes, java.nio.charset.Charset charset) decode Helper CharsetDecoder decoder = charset.newDecoder(); CharBuffer charBuffer = null; try { charBuffer = decoder.decode(ByteBuffer.wrap(byteArray, 0, numberOfBytes)); } catch (MalformedInputException ex) { charBuffer = null; return charBuffer; ... |
String | decodeOrDefault(byte[] data, Charset charset, String defaultValue) decode Or Default if (data == null) { return defaultValue; checkNotNull(charset, "charset"); try { return charset.newDecoder().decode(ByteBuffer.wrap(data)).toString(); } catch (CharacterCodingException ex) { return defaultValue; ... |