int recLengthWords, recLengthBytes, recNumber;
int recLengthWords, recLengthBytes;
    protected static void indexPolygons(InputStream is, long ptr,                                        OutputStream os) {        boolean moreRecords = true;        byte rHdr[] = new byte[SHAPE_RECORD_HEADER_LENGTH];        byte outBuf[] = new byte[SPATIAL_INDEX_RECORD_LENGTH];        int result;        int nRecords = 0;        int recLengthWords, recLengthBytes, recNumber;        long recOffset;        int recBufSize = 100000;        byte recBuf[] = new byte[recBufSize];        ESRIBoundingBox polyBounds;        try {            while (moreRecords) {                result = is.read(rHdr, 0, SHAPE_RECORD_HEADER_LENGTH);                if (result < 0) {                    moreRecords = false;                    Debug.output("Shapefile SpatialIndex Found " + nRecords                            + " records");                    Debug.output("Shapefile SpatialIndex recBufSize = "                            + recBufSize);                } else {                    nRecords++;                    recOffset = ptr;                    recNumber = readBEInt(rHdr, 0);                    recLengthWords = readBEInt(rHdr, 4);                    recLengthBytes = recLengthWords * 2;                    if (recLengthBytes > recBufSize) {                        Debug.output("Shapefile SpatialIndex increasing recBufSize to "                                + recLengthBytes);                        recBufSize = recLengthBytes;                        recBuf = new byte[recBufSize];                    }                    result = is.read(recBuf, 0, recLengthBytes);                    polyBounds = readBox(recBuf, 4);                    ptr += recLengthBytes + 8;                    writeBEInt(outBuf, 0, (int) (recOffset / 2));                    writeBEInt(outBuf, 4, recLengthWords);                    writeLEDouble(outBuf, 8, polyBounds.min.x);                    writeLEDouble(outBuf, 16, polyBounds.min.y);                    writeLEDouble(outBuf, 24, polyBounds.max.x);                    writeLEDouble(outBuf, 32, polyBounds.max.y);                    os.write(outBuf, 0, SPATIAL_INDEX_RECORD_LENGTH);                }            }        } catch (java.io.IOException e) {            e.printStackTrace();        } finally {            try {                is.close();            } catch (java.io.IOException e) {            }        }    }