public int removeColumn ( String inFieldName ) { int retCol = - 1 ; int tempLength = 1 ; DbaseField [ ] tempFieldDescriptors = new DbaseField [ fields . length - 1 ] ; for ( int i = 0 , j = 0 ; i < fields . length ; i ++ ) { if ( ! inFieldName . equalsIgnoreCase ( fields [ i ] . fieldName . trim ( ) ) ) { // if this is the last field and we still haven't found the // named field if ( i == j && i == fields . length - 1 ) { throw new IllegalArgumentException ( "Could not find a field named '" + inFieldName + "' for removal" ) ; } tempFieldDescriptors [ j ] = fields [ i ] ; tempFieldDescriptors [ j ] . fieldDataAddress = tempLength ; tempLength += tempFieldDescriptors [ j ] . fieldLength ; // only increment j on non-matching fields j ++ ; } else { retCol = i ; } } // set the new fields. fields = tempFieldDescriptors ; headerLength = 33 + 32 * fields . length ; recordLength = tempLength ; return retCol ; }
Remove a column from this DbaseFileHeader .