opendap/src/main/java/opendap/dap/DVector.java
public synchronized void deserialize(DataInputStream source,
                                         ServerVersion sv,
                                         StatusUI statusUI)
            throws IOException,
            EOFException,
            DataReadException {

        // Because arrays of primitive types (ie int32, float32, byte, etc) are
        // handled in the C++ core using the XDR package we must read the
        // length twice for those types. For BaseType vectors, we should read
        // it only once. This is in effect a work around for a bug in the C++
        // core as the C++ core does not consume 2 length values for the
        // BaseType vectors. Bummer...

        int length;
        length = source.readInt();

        if (!(vals instanceof BaseTypePrimitiveVector)) {
            // because both XDR and OPeNDAP write the length, we must read it twice
            int length2 = source.readInt();
            //LogStream.out.println("array1 length read: "+getName()+" "+length+ " -- "+length2);
            //LogStream.out.println("  array type = : "+vals.getClass().getName());

            // QC the second length
            if (length != length2) {
                throw new DataReadException("Inconsistent array length read: " + length + " != " + length2);
            }
        } /* else {
          LogStream.dbg.println("array2 length read: "+getName()+" "+length);
          LogStream.dbg.println("  array type = : "+vals.getClass().getName());
        } */

        if (length < 0)
            throw new DataReadException("Negative array length read.");
        if (statusUI != null)
            statusUI.incrementByteCount(8);
        vals.setLength(length);
        vals.deserialize(source, sv, statusUI);
    }
public synchronized void deserialize(DataInputStream source,
                                         ServerVersion sv,
                                         StatusUI statusUI)
            throws IOException,
            EOFException,
            DataReadException {

        // Because arrays of primitive types (ie int32, float32, byte, etc) are
        // handled in the C++ core using the XDR package we must read the
        // length twice for those types. For BaseType vectors, we should read
        // it only once. This is in effect a work around for a bug in the C++
        // core as the C++ core does not consume 2 length values for the
        // BaseType vectors. Bummer...

        int length;
        length = source.readInt();

        if (!(vals instanceof BaseTypePrimitiveVector)) {
            // because both XDR and OPeNDAP write the length, we must read it twice
            int length2 = source.readInt();
            //LogStream.out.println("array1 length read: "+getName()+" "+length+ " -- "+length2);
            //LogStream.out.println("  array type = : "+vals.getClass().getName());

            // QC the second length
            if (length != length2) {
                throw new DataReadException("Inconsistent array length read: " + length + " != " + length2);
            }
        } /* else {
          LogStream.dbg.println("array2 length read: "+getName()+" "+length);
          LogStream.dbg.println("  array type = : "+vals.getClass().getName());
        } */

        if (length < 0)
            throw new DataReadException("Negative array length read.");
        if (statusUI != null)
            statusUI.incrementByteCount(8);
        vals.setLength(length);
        vals.deserialize(source, sv, statusUI);
    }
Reads data from a <code>DataInputStream</code>. This method is only used
on the client side of the OPeNDAP client/server connection.

@param source   a <code>DataInputStream</code> to read from.
@param sv       the <code>ServerVersion</code> returned by the server.
@param statusUI the <code>StatusUI</code> object to use for GUI updates
and user cancellation notification (may be null).
@throws EOFException      if EOF is found before the variable is completely
deserialized.
@throws IOException       thrown on any other InputStream exception.
@throws DataReadException if an unexpected value was read.
@see ClientIO#deserialize(DataInputStream, ServerVersion, StatusUI)