private MatText readTextArray(byte[] name, int[] dim, int P) {
        MatText data = new MatText(new String(name), dim);
        switch (P) {
            case P_DOUBLE:

            // they are stored as a list of rows, so we read them in as
                // such.  This looks kind of backwards, but it works.
                for (int i = 0; i < dim[1]; i++) {
                    for (int j = 0; j < dim[0]; j++) {
                        int[] index = new int[2];
                        index[0] = j;
                        index[1] = i;
                        data.putValue(index, bBuf.getDouble());
                    }
                }
                return data;
            case P_SINGLE:

            // they are stored as a list of rows, so we read them in as
                // such.  This looks kind of backwards, but it works.
                for (int i = 0; i < dim[1]; i++) {
                    for (int j = 0; j < dim[0]; j++) {
                        int[] index = new int[2];
                        index[0] = j;
                        index[1] = i;
                        data.putValue(index, bBuf.getFloat());
                    }
                }
                return data;
            case P_8:
             // they are stored as a list of rows, so we read them in as
                // such.  This looks kind of backwards, but it works.
                for (int i = 0; i < dim[1]; i++) {
                    for (int j = 0; j < dim[0]; j++) {
                        int[] index = new int[2];
                        index[0] = j;
                        index[1] = i;
                        data.putValue(index, bBuf.get());
                    }
                }
                return data;
            default:
                throw new java.lang.UnsupportedOperationException(
                        "Invalid data type");
        }

    }