From 1b9f09542671ceea532265aecf31797328c4dca2 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Thu, 5 Jul 2018 22:49:16 +0200 Subject: [PATCH] Strip trailing space in hexdump --- .../openscale/core/bluetooth/BluetoothCommunication.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java index bbc9a742..774fe77a 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java @@ -371,12 +371,16 @@ public abstract class BluetoothCommunication { return ""; } + if (data.length == 0) { + return ""; + } + final StringBuilder stringBuilder = new StringBuilder(3 * data.length); for (byte byteChar : data) { stringBuilder.append(String.format("%02X ", byteChar)); } - return stringBuilder.toString(); + return stringBuilder.substring(0, stringBuilder.length() - 1); } protected byte xorChecksum(byte[] data, int offset, int length) {