Util.java
Go to the documentation of this file.
00001 package com.rocon.nfc;
00002 
00003 public class Util {
00004 
00005         // Hex help
00006                 private static final byte[] HEX_CHAR_TABLE = { (byte) '0', (byte) '1',
00007                                 (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6',
00008                                 (byte) '7', (byte) '8', (byte) '9', (byte) 'A', (byte) 'B',
00009                                 (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F' };
00010                                 
00011                 public Util() {
00012                         // TODO Auto-generated constructor stub
00013                 }
00014                 
00015                 public static String getHexString(byte[] raw, int len) {
00016                         byte[] hex = new byte[3 * len];
00017                         int index = 0;
00018                         int pos = 0;
00019 
00020                         for (byte b : raw) {
00021                                 if (pos >= len)
00022                                         break;
00023 
00024                                 pos++;
00025                                 int v = b & 0xFF;
00026                                 hex[index++] = HEX_CHAR_TABLE[v >>> 4];
00027                                 hex[index++] = HEX_CHAR_TABLE[v & 0xF];
00028                                 hex[index++] = ' ';
00029                         }
00030 
00031                         return new String(hex);
00032                 }
00033                 
00034                 public static byte[] concat(byte[]... arrays) {
00035                 int length = 0;
00036                 for (byte[] array : arrays) {
00037                         length += array.length;
00038                 }
00039                 
00040                 byte[] result = new byte[length];
00041                 int pos = 0;
00042                 for (byte[] array : arrays) {
00043                         System.arraycopy(array, 0, result, pos, array.length);
00044                         pos += array.length;
00045                 }
00046                 
00047                 return result;
00048             }
00049                 
00050 }


android_remocons
Author(s): Daniel Stonier , Kazuto Murase
autogenerated on Wed Aug 26 2015 10:40:28