Java Hex Calculate toHexString(byte[] bytes)

Here you can find the source of toHexString(byte[] bytes)

Description

to Hex String

License

Open Source License

Declaration

public static String toHexString(byte[] bytes) 

Method Source Code

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

public class Main {
    public static String toHexString(byte[] bytes) {
        if (bytes != null) {
            return toHexString(bytes, 0, bytes.length);
        } else {/*from w w  w .j a  v a 2  s.  c o m*/
            return null;
        }
    }

    public static String toHexString(byte[] bytes, int offset, int count) {
        if (bytes != null) {
            StringBuffer sb = new StringBuffer(count * 2);
            for (int i = offset; i < offset + count; ++i) {
                int c = bytes[i] & 0xFF;
                if (c < 16) {
                    sb.append('0');
                }
                sb.append(Integer.toHexString(c));
            }

            return sb.toString();
        } else {
            return null;
        }
    }
}

Related

  1. toHexString(byte[] byteArray, String delim)
  2. toHexString(byte[] byteDigest)
  3. toHexString(byte[] bytes)
  4. toHexString(byte[] bytes)
  5. toHexString(byte[] bytes)
  6. toHexString(byte[] bytes)
  7. toHexString(byte[] bytes)
  8. toHexString(byte[] bytes)
  9. toHexString(byte[] bytes)