*/
public void pack()
throws xBaseJException, IOException, SecurityException, CloneNotSupportedException
{
Field Fields[] = new Field[fldcount];
int i, j;
for (i=1; i<=fldcount; i++)
{
Fields[i-1] = (Field) getField(i).clone();
}
String parent = ffile.getParent();
if (parent == null)
parent = ".";
String tempname = new String(parent + File.separator + "temp.tmp");
DBF tempDBF = new DBF(tempname, version, true);
tempDBF.MDX_exist = MDX_exist;
tempDBF.addField(Fields);
Field t, p;
for (i=1; i <= count; i++)
{
gotoRecord(i);
if (deleted()) {
continue;
}
for (j=1; j<=fldcount; j++)
{
t = tempDBF.getField(j);
p = getField(j);
t.put(p.get());
}
tempDBF.write();
}
file.close();
ffile.delete();
tempDBF.renameTo(dosname);
//if (dbtobj != null && tempDBF.dbtobj == null) {
if (dbtobj != null) {
dbtobj.file.close();
dbtobj.thefile.delete();
}
if (tempDBF.dbtobj != null) {
// tempDBF.dbtobj.file.close();
tempDBF.dbtobj.rename(dosname);
dbtobj = tempDBF.dbtobj;
Field tField;
MemoField mField;
for (i=1; i<=fldcount;i++) {
tField = getField(i);
if (tField instanceof MemoField) {
mField = (MemoField) tField;