Java examples for java.lang:byte Array to String
hex String To Byte array
//package com.java2s; public class Main { public static byte[] hexToBytes(String str) { if (str == null) { return null; } else if (str.length() < 2) { return null; } else {/*from w w w .j a v a 2 s. c o m*/ int len = str.length() / 2; byte[] buffer = new byte[len]; for (int i = 0; i < len; i++) { buffer[i] = (byte) Integer.parseInt( str.substring(i * 2, i * 2 + 2), 16); } return buffer; } } }