question: private void toHexString ( ) { String pubText = pubData . getText ( ) ; StringBuffer hexText = new StringBuffer ( ) ; byte [ ] pubBytes = pubText . getBytes ( ) ; for ( int i = 0 ; i < pubBytes . length ; i ++ ) { int byteValue = pubBytes [ i ] ; if ( byteValue < 0 ) { byteValue += 256 ; } if ( byteValue < 16 ) { hexText . append ( "0" + Integer . toHexString ( byteValue ) ) ; } else { hexText . append ( Integer . toHexString ( byteValue ) ) ; } } hexDisplay = true ; pubLabel . setText ( PANEL_TITLE + " - hexadecimal display" ) ; mqttMgr . setTitleText ( "" ) ; hexButton . setText ( "Text" ) ; pubData . setText ( hexText . toString ( ) ) ; }
target:  This method reads in the data from the publish text area as text characters and converts them into hex characters (i.e. every character read is represented as two hex characters). It is used when the button saying 'Hex' is pressed indicating that the text data in the data area needs to be converted to a hex representation.<BR> The text string read in from the data area is converted into an array of bytes. The integer value of each byte is then converted into a hex string representation and append to the output string buffer. Once the entire input string has been processed the output string is written back to the text area.