List of utility methods to do Convert via ByteBuffer
String | toString(Reader reader) to String StringWriter sw = new StringWriter(); copyStream(reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader), new BufferedWriter(sw)); return sw.toString(); |
String | toText(@Nonnull byte[] bytes) to Text StringBuilder buf = new StringBuilder(); for (byte b : bytes) { if (Character.isValidCodePoint(b)) buf.append((char) b); else buf.append("\\x").append(UnsignedBytes.toString(b, 16)); return buf.toString(); ... |
byte[] | toThriftBinary(UUID uuid) to Thrift Binary ByteBuffer bb = ByteBuffer.wrap(new byte[UUID_BYTES]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return bb.array(); |
URI | toURI(String value) Convert a string to java.net.URI If part name is not a valid URI, it is resolved as follows: 1. if (value.indexOf("\\") != -1) { value = value.replace('\\', '/'); int fragmentIdx = value.indexOf('#'); if (fragmentIdx != -1) { String path = value.substring(0, fragmentIdx); String fragment = value.substring(fragmentIdx + 1); value = path + "#" + encode(fragment); ... |
String | toUTF(byte[] bytes) Converts a byte array into an UTF String. int codePoint = ByteBuffer.wrap(bytes).getInt(); if (codePoint < 0 || codePoint > 0X10FFFF) throw new IllegalArgumentException("RangeError: pack(U): value out of range"); return String.valueOf((char) codePoint); |
byte[] | toUTF8(String str) In all src and test code, the String(byte[], ...) constructor and String.getBytes method must always be passed a Charset, to avoid portability issues. try { return str.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); |
UUID | toUuid(byte[] bytes) to Uuid ByteBuffer bb = ByteBuffer.wrap(bytes); long hi = bb.getLong(); long lo = bb.getLong(); return new UUID(hi, lo); |
java.util.UUID | toUUID(byte[] uuid) Returns an instance of uuid. return uuid(uuid, 0);
|
byte[] | toUUIDBinary(UUID uuid) to UUID Binary ByteBuffer bb = ByteBuffer.allocate(16);
bb.putLong(uuid.getMostSignificantBits()).putLong(uuid.getLeastSignificantBits());
return bb.array();
|