From c099628f0cd07ca6545773a69824b567a6610675 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 1 Jul 2015 11:04:03 +1200 Subject: Add byte array conversion method --- src/org/traccar/helper/ChannelBufferTools.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/org/traccar') diff --git a/src/org/traccar/helper/ChannelBufferTools.java b/src/org/traccar/helper/ChannelBufferTools.java index 09e3d5191..ef9384138 100644 --- a/src/org/traccar/helper/ChannelBufferTools.java +++ b/src/org/traccar/helper/ChannelBufferTools.java @@ -15,6 +15,7 @@ */ package org.traccar.helper; +import java.math.BigInteger; import java.util.Formatter; import org.jboss.netty.buffer.ChannelBuffer; import org.traccar.protocol.IntellitracFrameDecoder; @@ -144,4 +145,16 @@ public class ChannelBufferTools { return out; } + /** + * Convert byte array to hex string + */ + public static String convertByteArray(byte[] in) { + StringBuilder out = new StringBuilder(); + Formatter formatter = new Formatter(out); + for (byte b : in) { + formatter.format("%02x", b); + } + return out.toString(); + } + } -- cgit v1.2.3