Java ByteBuffer to Hex toHexString(ByteBuffer buffer)

Here you can find the source of toHexString(ByteBuffer buffer)

Description

to Hex String

License

Open Source License

Declaration

public static String toHexString(ByteBuffer buffer) 

Method Source Code

//package com.java2s;

import java.nio.ByteBuffer;

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

    public static String toHexString(ByteBuffer buffer) {
        final StringBuilder r = new StringBuilder(buffer.remaining() * 2);
        while (buffer.hasRemaining()) {
            final byte b = buffer.get();
            r.append(HEX_CODE[(b >> 4) & 0xF]);
            r.append(HEX_CODE[(b & 0xF)]);
        }/*w ww .j av  a2s .  c o m*/
        return r.toString();
    }
}

Related

  1. toHexStr(final ByteBuffer data)
  2. toHexStream(ByteBuffer data)
  3. toHexString(ByteBuffer bb)
  4. toHexString(ByteBuffer bb)
  5. toHexString(ByteBuffer bb, boolean withSpaces)
  6. toHexString(ByteBuffer buffer)
  7. toHexString(ByteBuffer buffer, int size)
  8. toHexString(ByteBuffer byteBuffer)
  9. toHexString(ByteBuffer byteBuffer)