NX: contractor data file.

Yuan Ye

Ranch Hand

Posts: 172

posted 13 years ago

Hi. all. I have two questions about reading the data file. 1. After I get the head infomation of each records (name & length of each field), the length is used to read the data, what's the usage of name? Since I may already defined a similar name in the Contractor class. 2. How to use ByteBuffer to get a string value of n bytes. Should I use the getChar() method? Thanks in advance

Tony Collins

Ranch Hand

Posts: 435

posted 13 years ago

1) I used the names as the column headings of my JTable. 2) I assume you've read the data into a byte buffer with a file channel. Use .array() and construct a string as below, remember to specify how the bytes are encoded.

Tony

Yuan Ye

Ranch Hand

Posts: 172

posted 13 years ago

I can use the field name as table header, do we also must construct our data class using the field names? To have property names exactly match the name defined by the db file. Thanks

or some combination (e.g. use descriptive names whenever a recognised real name is found, otherwise use the real name).

If the first option, do you do some translation from the descriptive to the stored names? Also, do you verify that the field names in the physical file do match the expected values? Some positive aspects of either option: Using the names from the physical file means that you are less likely to be affected if a column changes position, or a new column is added. Using the descriptive names may be more user friendly. Regards, Andrew