From: felix Date: Thu, 17 May 2007 13:29:33 +0000 (+0000) Subject: - Entfernt Leerzeichen am Anfang und Ende von CommandStrings X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=be01341a0647b30c45e61db7ba8c4e46ba6718fd;p=bytewurf.git - Entfernt Leerzeichen am Anfang und Ende von CommandStrings - Fügt 0x bei der Ausgabe an Hexzahlen vor git-svn-id: https://www.internetallee.de/svn/bytewurf@31 a944a559-bf0e-0410-8ddc-85264b264b6c --- diff --git a/projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/Command.java b/projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/Command.java index adcd547..60548c8 100644 --- a/projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/Command.java +++ b/projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/Command.java @@ -13,7 +13,7 @@ public class Command { byte[] commandBytes; Command(String commandString) { - String[] commands = commandString.split("[\t\n ,]+", 100); + String[] commands = commandString.trim().split("[\t\n ,]+", 100); commandBytes = new byte[commands.length]; try { for (int i = 0; i < commands.length; i++) { @@ -28,7 +28,7 @@ public class Command { public String toString() { StringBuffer result = new StringBuffer(); for (int i = 0; i < commandBytes.length; i++) { - result.append(Integer.toHexString(commandBytes[i] & 0xFF)); + result.append("0x" + Integer.toHexString(commandBytes[i] & 0xFF)); if (i < commandBytes.length - 1); result.append(", "); }