DbaseFileWriter and number of registers

2 messages Options
Embed this post
Permalink
César Martínez Izquierdo-3

DbaseFileWriter and number of registers

Reply Threaded More More options
Print post
Permalink
Hello list,
I'm writing a DBF file using a code like this:

  DbaseFileHeader header = getHeader();
  WritableByteChannel out = new FileOutputStream(filename).getChannel();
  DbaseFileWriter writer = new DbaseFileWriter(header, out);
  for (int i=0; i<NUMROWS; i++) {
    writer.write(getRow());
  }
  writer.close();

I'd expect that when I close the file, the number of registers gets
updated in the DBF header.

However, it seems that it is not actually updated and the header ends
with a value of 0 (zero) registers, which means that
DbaseFileReader.hasNext() will always return false for this file.

This is a pity, it means I can't write a proper DBF unless I know the
number of registers in advance.
Am I missing something here?

Regards,

César

--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   César Martínez Izquierdo
   GIS developer
   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
   ETC-LUSI: http://etc-lusi.eionet.europa.eu/
   Universitat Autònoma de Barcelona (SPAIN)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
César Martínez Izquierdo-3

Re: DbaseFileWriter and number of registers

Reply Threaded More More options
Print post
Permalink
Hello again,

I've created a patch which solves the problem, please have a look at it.
I work on 2.5.x branch.

Regards,

César


El día 15 de octubre de 2009 15:52, César Martínez Izquierdo
<[hidden email]> escribió:

> Hello list,
> I'm writing a DBF file using a code like this:
>
>  DbaseFileHeader header = getHeader();
>  WritableByteChannel out = new FileOutputStream(filename).getChannel();
>  DbaseFileWriter writer = new DbaseFileWriter(header, out);
>  for (int i=0; i<NUMROWS; i++) {
>    writer.write(getRow());
>  }
>  writer.close();
>
> I'd expect that when I close the file, the number of registers gets
> updated in the DBF header.
>
> However, it seems that it is not actually updated and the header ends
> with a value of 0 (zero) registers, which means that
> DbaseFileReader.hasNext() will always return false for this file.
>
> This is a pity, it means I can't write a proper DBF unless I know the
> number of registers in advance.
> Am I missing something here?
>
> Regards,
>
> César
>
> --
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>   César Martínez Izquierdo
>   GIS developer
>   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
>   ETC-LUSI: http://etc-lusi.eionet.europa.eu/
>   Universitat Autònoma de Barcelona (SPAIN)
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>


--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   César Martínez Izquierdo
   GIS developer
   -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
   ETC-LUSI: http://etc-lusi.eionet.europa.eu/
   Universitat Autònoma de Barcelona (SPAIN)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

DbaseFileWriter.java.patch (2K) Download Attachment