List of utility methods to do Byte Array Encode
byte[] | encode(byte[] message) Apply DEFLATE encoding ByteArrayOutputStream baos = new ByteArrayOutputStream(); Deflater deflater = new Deflater(Deflater.DEFLATED, true); DeflaterOutputStream deflaterStream = new DeflaterOutputStream(baos, deflater); deflaterStream.write(message); deflaterStream.finish(); return baos.toByteArray(); |
String | encode(byte[] rawData) encode StringBuilder hexText = new StringBuilder(); String initialHex = null; int initHexLength = 0; for (int i = 0; i < rawData.length; i++) { int positiveValue = rawData[i] & 0x000000FF; initialHex = Integer.toHexString(positiveValue); initHexLength = initialHex.length(); while (initHexLength++ < 2) { ... |
String | encode(byte[] source) Encodes a byte array into Base64 notation. byte[] encoded = encodeBytesToBytes(source, source.length); try { return new String(encoded, "US-ASCII"); } catch (java.io.UnsupportedEncodingException uue) { return new String(encoded); |
void | encode(String prefix, byte[] buf, ZipOutputStream zos, File[] files) encode for (File f : files) { try { if (f.isDirectory()) { encode(prefix, buf, zos, f.listFiles()); } else { ZipEntry entry = new ZipEntry(f.getPath().replace(prefix, "").replace('\\', '/')); zos.putNextEntry(entry); try (InputStream is = new BufferedInputStream(new FileInputStream(f))) { ... |
String | encodeAsUtf8(byte[] bytes) encode As Utf try { return new String(bytes, UTF_8); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); |
void | encodeBitString(byte[] in, OutputStream os) encode Bit String os.write(BIT_STRING); writeLength(in.length + 1, os); os.write(0); os.write(in); |
void | encodeByteArray(DataOutputStream out, byte[] bytes) encode Byte Array if (bytes == null) { out.writeInt(-1); return; out.writeInt(bytes.length); out.write(bytes); |
String | encodeBytes(byte[] source, int off, int len) Encodes a byte array into Base64 notation. byte[] encoded = encodeBytesToBytes(source, off, len); try { return new String(encoded, PREFERRED_ENCODING); } catch (UnsupportedEncodingException uee) { return new String(encoded); |
byte[] | encodeCompositeAlways(List makes composite column name or row key byte[] encBytes; ByteArrayOutputStream bos = new ByteArrayOutputStream(); for (byte[] bytes : bytesList) { bos.write((byte) ((bytes.length >> 8) & 0xFF)); bos.write((byte) (bytes.length & 0xFF)); for (int j = 0; j < bytes.length; j++) { bos.write(bytes[j] & 0xFF); bos.write((byte) 0); encBytes = bos.toByteArray(); return encBytes; |
String | encodeDataWithCharsetInMetaTag(byte[] data) encode Data With Charset In Meta Tag Matcher m = characterEncodingPattern.matcher(new String(data, "ISO-8859-1")); if (m.find()) { String foundCharset = m.group(1); if (foundCharset.toLowerCase().equals("iso-8859-1")) { logger.info("ISO-8859-1 found in meta tag, usind windows-1252 instead"); foundCharset = DEFAULT_CHARACTER_ENCODING; return new String(data, foundCharset); ... |