- Entfernt Leerzeichen am Anfang und Ende von CommandStrings
authorfelix <felix@a944a559-bf0e-0410-8ddc-85264b264b6c>
Thu, 17 May 2007 13:29:33 +0000 (13:29 +0000)
committerfelix <felix@a944a559-bf0e-0410-8ddc-85264b264b6c>
Thu, 17 May 2007 13:29:33 +0000 (13:29 +0000)
- Fügt 0x bei der Ausgabe an Hexzahlen vor

git-svn-id: https://www.internetallee.de/svn/bytewurf@31 a944a559-bf0e-0410-8ddc-85264b264b6c

projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/Command.java

index adcd547..60548c8 100644 (file)
@@ -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(", ");
                }