Code example for DataInput

Methods: readFully, readInt

0
		else 
			out.writeInt(0);
	} 
	 
	public static String readString(DataInput in) throws IOException {
		int len = in.readInt();
		if(len > 0) {
			byte[] encodedBody = new byte[len];
			in.readFully(encodedBody, 0, len);
			return new String(encodedBody, "UTF-8");
		} 
		else 
			return null; 
	} 
	 
	@SuppressWarnings("unchecked") 
	public static <T> List<T> readList(DataInput in, Class<T> type) throws IOException {
		int length = in.readInt();
		 
		List<T> result = new ArrayList<T>(length);