public synchronized String getString ( ) { checkReleased ( ) ; String returningString = null ; // Read the length in short stringLength = receivedBuffer . getShort ( ) ; // Allocate the right amount of space for it byte [ ] stringBytes = new byte [ stringLength ] ; // And copy the data in receivedBuffer . get ( stringBytes ) ; // If the length is 1, and the byte is 0x00, then this is null - so do nothing if ( stringLength == 1 && stringBytes [ 0 ] == 0 ) { // String is null... } else { try { returningString = new String ( stringBytes , stringEncoding ) ; } catch ( UnsupportedEncodingException e ) { FFDCFilter . processException ( e , CLASS_NAME + ".getString" , CommsConstants . COMMSBYTEBUFFER_GETSTRING_01 , this ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { SibTr . debug ( tc , "Unable to encode String: " , e ) ; SibTr . exception ( tc , e ) ; } SibTr . error ( tc , "UNSUPPORTED_STRING_ENCODING_SICO8005" , new Object [ ] { stringEncoding , e } ) ; throw new SIErrorException ( TraceNLS . getFormattedMessage ( CommsConstants . MSG_BUNDLE , "UNSUPPORTED_STRING_ENCODING_SICO8005" , new Object [ ] { stringEncoding , e } , null ) ) ; } } return returningString ; }
Reads a String from the current position in the byte buffer .