public static final String getString ( byte [ ] data , int offset ) { StringBuilder buffer = new StringBuilder ( ) ; char c ; for ( int loop = 0 ; offset + loop < data . length ; loop ++ ) { c = ( char ) data [ offset + loop ] ; if ( c == 0 ) { break ; } buffer . append ( c ) ; } return ( buffer . toString ( ) ) ; }
Reads a string of single byte characters from the input array . This method assumes that the string finishes either at the end of the array or when char zero is encountered . Reading begins at the supplied offset into the array .