question: static final byte [ ] RLEStringToByteArray ( String s ) { int length = ( ( ( int ) s . charAt ( 0 ) ) << 16 ) | ( ( int ) s . charAt ( 1 ) ) ; byte [ ] array = new byte [ length ] ; boolean nextChar = true ; char c = 0 ; int node = 0 ; int runLength = 0 ; int i = 2 ; for ( int ai = 0 ; ai < length ; ) { byte b ; if ( nextChar ) { c = s . charAt ( i ++ ) ; b = ( byte ) ( c > > 8 ) ; nextChar = false ; } else { b = ( byte ) ( c & 0xFF ) ; nextChar = true ; } switch ( node ) { case 0 : if ( b == ESCAPE_BYTE ) { node = 1 ; } else { array [ ai ++ ] = b ; } break ; case 1 : if ( b == ESCAPE_BYTE ) { array [ ai ++ ] = ESCAPE_BYTE ; node = 0 ; } else { runLength = b ; if ( runLength < 0 ) runLength += 0x100 ; node = 2 ; } break ; case 2 : for ( int j = 0 ; j < runLength ; ++ j ) array [ ai ++ ] = b ; node = 0 ; break ; } } if ( node != 0 ) throw new InternalError ( "Bad run-length encoded byte array" ) ; if ( i != s . length ( ) ) throw new InternalError ( "Excess data in RLE byte array string" ) ; return array ; }
target:  Construct an array of bytes from a run-length encoded string.