private void writeFieldHeader(JDBField jdbfield) throws IOException {
        byte[] bfr;
        int RecordHeaderSize = 0;
        int ofset = 0;
        if (dbfConfig.getDbfVersion() == ru.nyrk.util.jdbf.DBFConfig.DbfVersion.xBaseVII) {
            RecordHeaderSize = 48;
            ofset = 31;
        } else {
            RecordHeaderSize = 32;
            ofset = 10;
        }
        bfr = new byte[RecordHeaderSize];
        String s = jdbfield.getName();

        int i = s.length();
        if (i > ofset)
            i = ofset;
        for (int j = 0; j < i; j++)
            bfr[j] = (byte)s.charAt(j);

        bfr[ofset + 1] = (byte)jdbfield.getType();


        if (dbfConfig.getDbfVersion() == ru.nyrk.util.jdbf.DBFConfig.DbfVersion.xBaseVII) {
            bfr[ofset + 2] = (byte)jdbfield.getLength();
            bfr[ofset + 3] = (byte)jdbfield.getDecimalCount();
            
            int seg = 1;
            for (int j = 0; j < jdbfield.getIndex(); j++) {
                seg += fields[j].getLength();
            }
            int smeh=4;
            byte[] b = intToByteArray(seg);
            for (int j = ofset + smeh; j < ofset + smeh+4; j++)
                bfr[j] = (byte)b[j - (ofset+smeh)];
            
        } else {
            int seg = 1;
            for (int j = 0; j < jdbfield.getIndex(); j++) {
                seg += fields[j].getLength();
            }

            byte[] b = intToByteArray(seg);
            for (int j = ofset + 2; j < ofset + 6; j++)
                bfr[j] = (byte)b[j - (ofset+2)];
            bfr[ofset + 6] = (byte)jdbfield.getLength();
            bfr[ofset + 7] = (byte)jdbfield.getDecimalCount();
        }

        stream.write(bfr, 0, bfr.length);
    }