Java ByteBuffer to Hex asHexString(StringBuilder temp, ByteBuffer buffer)

Here you can find the source of asHexString(StringBuilder temp, ByteBuffer buffer)

Description

as Hex String

License

Open Source License

Declaration

static StringBuilder asHexString(StringBuilder temp, ByteBuffer buffer) 

Method Source Code

//package com.java2s;
// *|            This source code is provided under the Apache 2.0 license      --

import java.nio.ByteBuffer;

public class Main {
    static StringBuilder asHexString(StringBuilder temp, ByteBuffer buffer) {
        int limit = buffer.limit();
        for (int i = buffer.position(); i < limit; i++)
            temp.append(i + 1 == limit ? String.format("%02x",
                    buffer.get(i)) : String.format("%02x ", buffer.get(i)));

        return temp;
    }/*from  w ww  .  j a  va 2 s  .  c  o  m*/
}

Related

  1. asHexString(ByteBuffer buffer)
  2. byteBufferToHex(ByteBuffer buffer)
  3. bytesToHex(ByteBuffer bytes)
  4. bytesToHex(ByteBuffer bytes)
  5. bytesToHexString(ByteBuffer b)