Java ByteBuffer to Hex bytesToHex(ByteBuffer bytes)

Here you can find the source of bytesToHex(ByteBuffer bytes)

Description

bytes To Hex

License

Open Source License

Declaration

public static String bytesToHex(ByteBuffer bytes) 

Method Source Code


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

import java.nio.ByteBuffer;

public class Main {
    private final static char[] hexArray = "0123456789ABCDEF".toCharArray();

    public static String bytesToHex(ByteBuffer bytes) {
        char[] hexChars = new char[bytes.limit() * 2];
        for (int j = 0; j < bytes.limit(); j++) {
            int v = bytes.get() & 0xFF;
            hexChars[j * 2] = hexArray[v >>> 4];
            hexChars[j * 2 + 1] = hexArray[v & 0x0F];
        }/*from   www.java 2 s  .  c  o m*/
        return new String(hexChars);
    }
}

Related

  1. asHexString(ByteBuffer buffer)
  2. asHexString(StringBuilder temp, ByteBuffer buffer)
  3. byteBufferToHex(ByteBuffer buffer)
  4. bytesToHex(ByteBuffer bytes)
  5. bytesToHexString(ByteBuffer b)
  6. toHex(ByteBuffer bb)
  7. toHex(ByteBuffer bb)