Java Byte Array to String bytesToString(byte[] input)

Here you can find the source of bytesToString(byte[] input)

Description

bytes To String

License

Open Source License

Declaration

public static String bytesToString(byte[] input) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static final char[] LOWERCASE_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c',
            'd', 'e', 'f' };

    public static String bytesToString(byte[] input) {
        return bytesToString(input, LOWERCASE_DIGITS);
    }// w  ww  .  j a  v  a  2  s.c  o  m

    public static String bytesToString(byte[] input, char[] digits) {
        char[] out = new char[input.length << 1];

        for (int i = 0, j = 0; i < input.length; i++) {
            out[j++] = digits[(0xF0 & input[i]) >>> 4];
            out[j++] = digits[0x0F & input[i]];
        }

        return new String(out);
    }
}

Related

  1. bytesToString(byte[] bytes, String encoding)
  2. bytesToString(byte[] data)
  3. bytesToString(byte[] data, int start, int end)
  4. bytesToString(byte[] hasher)
  5. bytesToString(byte[] id)
  6. bytesToString(byte[] myByte)
  7. bytesToString(byte[] value)
  8. bytesToString(char[] bytes, boolean le, boolean signed)
  9. bytesToString(final byte[] arr, final boolean signed, final boolean littleEndian, final String sep)