Back to project page android-nfc-reader.
The source code is released under:
MIT License
If you think the Android project android-nfc-reader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package net.mklbravo.lib.nfcreader.utils; /*from ww w . ja v a 2 s . c o m*/ import java.math.BigInteger; public class Converter { /** * Convert byte array into hexadecimal string */ public static String byteArrayToHexString(byte[] data) { if (data==null)return ""; return String.format("%0" + (data.length * 2) + "X", new BigInteger(1, data)); } /** * Convert a hexadecimal String into a byte array */ public static byte[] hexStringToByteArray(String s) { int len = s.length(); byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16)); } return data; } }