question: private void toCharString ( ) { String hexText = pubData . getText ( ) ; if ( hexText . length ( ) % 2 != 0 ) { mqttMgr . setTitleText ( "Odd number of hex characters!" ) ; } else { try { byte [ ] charArray = new byte [ hexText . length ( ) / 2 ] ; for ( int i = 0 ; i < charArray . length ; i ++ ) { charArray [ i ] = ( byte ) Integer . parseInt ( hexText . substring ( i * 2 , ( i * 2 ) + 2 ) , 16 ) ; } hexDisplay = false ; pubLabel . setText ( PANEL_TITLE + " - text display" ) ; mqttMgr . setTitleText ( "" ) ; hexButton . setText ( "Hex" ) ; pubData . setText ( new String ( charArray ) ) ; } catch ( NumberFormatException nfe ) { mqttMgr . setTitleText ( "Invalid hexadecimal data!" ) ; } } }
target:  This method reads in the data from the publish text area as hex and converts it into a text string (i.e. every two characters read are treated as hex and represent one char). It is used when the button saying 'Text' is pressed indicating that the hex data in the data area needs to be converted to character data.<BR> Error conditions checked for include an odd number of hex characters and invalid base 16 characters (not in [0..9],[A..F]).<BR> The hex input string is converted into a text character array then a new text string is generated from the character array and set as the string in the publication data area.