Here you can find the source of writeHexString(ByteBuffer buffer, String hex)
public static void writeHexString(ByteBuffer buffer, String hex)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static void writeHexString(ByteBuffer buffer, String hex) { byte[] bytes = hexStringToBytes(hex); for (int i = bytes.length - 1; i >= 0; i--) { buffer.put(bytes[i]);/*from w w w.j a v a 2 s. c o m*/ } } public static byte[] hexStringToBytes(String hex) { byte[] result = new byte[hex.length() / 2]; for (int i = 0; i < result.length; i++) { result[i] = (byte) Integer.parseInt(hex.substring(i * 2, i * 2 + 2), 16); } return result; } }