Java Utililty Methods Byte Array Encode

List of utility methods to do Byte Array Encode

  1. HOME
  2. Java
  3. B
  4. Byte Array Encode

Description

The list of methods to do Byte Array Encode are organized into topic(s).

Method

byte[] encode(byte[] b)
encode
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream b64os = MimeUtility.encode(baos, "base64");
b64os.write(b);
b64os.close();
return baos.toByteArray();
String encode(byte[] buf)
Converts specifed byte-array to hex-string.
StringBuffer result = new StringBuffer(2 * buf.length);
for (int i = 0; i < buf.length; i++) {
 int byteAsInt = buf[i] & 0xFF;
 if (byteAsInt < 16) {
 result.append("0");
 result.append(Integer.toString(byteAsInt, 16).toLowerCase());
return result.toString();
String encode(byte[] buff)
encode
if (null == buff)
 return null;
StringBuilder strBuilder = new StringBuilder("");
int paddingCount = (3 - (buff.length % 3)) % 3;
byte[] stringArray = zeroPad(buff.length + paddingCount, buff);
for (int i = 0; i < stringArray.length; i += 3) {
 int j = ((stringArray[i] & 0xff) << 16) + ((stringArray[i + 1] & 0xff) << 8)
 + (stringArray[i + 2] & 0xff);
...
void encode(byte[] buffer, int offset, int len, Writer out)
encode
ByteArrayInputStream in = new ByteArrayInputStream(buffer, offset, len);
encode(in, out);
byte[] encode(byte[] bytes)
encode
return encode(bytes, false);
String encode(byte[] bytes, boolean withNewLines)
Encode bytes using the Base64 algorithm (the linebreak after 76 signs can be optionally removed).
try {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 OutputStream os = MimeUtility.encode(baos, "base64");
 os.write(bytes);
 os.close();
 String str = new String(baos.toByteArray(), "utf8");
 if (!withNewLines)
 str = str.replaceAll("\r\n", "");
...
char[] encode(byte[] data)
encode
char[] out = new char[((data.length + 2) / 3) * 4];
for (int i = 0, index = 0; i < data.length; i += 3, index += 4) {
 boolean quad = false;
 boolean trip = false;
 int val = (0xFF & (int) data[i]);
 val <<= 8;
 if ((i + 1) < data.length) {
 val |= (0xFF & (int) data[i + 1]);
...
byte[] encode(byte[] data)
encode the input data producing a base 64 encoded byte array.
return encode(data, 0, data.length);
String encode(byte[] in, int len)
Encode a raw byte array to a Base64 String.
ByteArrayOutputStream baos = null;
ByteArrayInputStream bais = null;
try {
 baos = new ByteArrayOutputStream();
 bais = new ByteArrayInputStream(in);
 encode(bais, baos, len);
 return (new String(baos.toByteArray()));
} finally {
...
String encode(byte[] input)
Encodes the given bytes in base58.
if (input.length == 0) {
 return "";
input = copyOfRange(input, 0, input.length);
int zeroCount = 0;
while (zeroCount < input.length && input[zeroCount] == 0) {
 ++zeroCount;
byte[] temp = new byte[input.length * 2];
int j = temp.length;
int startAt = zeroCount;
while (startAt < input.length) {
 byte mod = divmod58(input, startAt);
 if (input[startAt] == 0) {
 ++startAt;
 temp[--j] = (byte) ALPHABET[mod];
while (j < temp.length && temp[j] == ALPHABET[0]) {
 ++j;
while (--zeroCount >= 0) {
 temp[--j] = (byte) ALPHABET[0];
byte[] output = copyOfRange(temp, j, temp.length);
try {
 return new String(output, "US-ASCII");
} catch (UnsupportedEncodingException e) {
 throw new RuntimeException(e); 


AltStyle によって変換されたページ (->オリジナル) /