public static String readString(DataInput in) throws IOException {
		// the length we read is offset by one, because a length of zero indicates a null value
		int len = in.readUnsignedByte();
		
		if (len == 0) {
			return null;
		}

		if (len >= HIGH_BIT) {
			int shift = 7;
			int curr;
			len = len & 0x7f;
			while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
				len |= (curr & 0x7f) << shift;
				shift += 7;
			}
			len |= curr << shift;
		}
		
		// subtract one for the null length
		len -= 1;
		
		final char[] data = new char[len];

		for (int i = 0; i < len; i++) {
			int c = in.readUnsignedByte();
			if (c < HIGH_BIT) {
				data[i] = (char) c;
			} else {
				int shift = 7;
				int curr;
				c = c & 0x7f;
				while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
					c |= (curr & 0x7f) << shift;
					shift += 7;
				}
				c |= curr << shift;
				data[i] = (char) c;
			}
		}
		
		return new String(data, 0, len);
	}
public static String readString ( DataInput in ) throws IOException { int len = in . readUnsignedByte ( ) ; if ( len == 0 ) { return null ; } if ( len >= HIGH_BIT ) { int shift = 7 ; int curr ; len = len & 0x7f ; while ( ( curr = in . readUnsignedByte ( ) ) >= HIGH_BIT ) { len |= ( curr & 0x7f ) << shift ; shift += 7 ; } len |= curr << shift ; } len -= 1 ; final char [ ] data = new char [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { int c = in . readUnsignedByte ( ) ; if ( c < HIGH_BIT ) { data [ i ] = ( char ) c ; } else { int shift = 7 ; int curr ; c = c & 0x7f ; while ( ( curr = in . readUnsignedByte ( ) ) >= HIGH_BIT ) { c |= ( curr & 0x7f ) << shift ; shift += 7 ; } c |= curr << shift ; data [ i ] = ( char ) c ; } } return new String ( data , 0 , len ) ; }
--------------------------------------------------------------------------------------------