Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

the create()

 
Jofer Chan
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,everyone:
use the create(String[] data) to create a new record,
every field have itself length(32,64,6,8,8) in the record ,
but the user data's length be likely to less than the field's length(32,64,6,8,8),
Example:
the name field's length is 32 in the db file ,
the new record's name filed's length is 5(example:"Jofer"),
how does the new record's name write into the db file?
Does append the 27 blanks to the "Jofer" with the "for" statement?
 
Terry Martinson
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I pad with spaces in both create and update functionality - see related padding url
TJ
 
Seid Myadiyev
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my specs it says that all text values are null terminated if less than maximum length but when I read record string array with RandomAccessFile I get text values padded with spaces.
May I just space-padd records before I write them back to disk?
Seid
 
Terry Martinson
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seid -
At the bottom of the prior posting, see the related padding url. If you look towards the bottom of that Topic, you will see a URL reference to another Topic that also deals with the space vs. null issue. Someone contacted Sun regarding this and they posted Sun's response.
Don't you just love ambiguous specs?

TJ
 
Seid Myadiyev
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Terry, thanks!
I read that post but was not sure what this meant:
"a) The file is valid. You've just used the maximum length of the field by padding with spaces and I should do the same. i.e. You are are trying to simulate typical semi-clueless customers, who says one thing but actually means something else. "
Thanks!
Seid
 
joe black
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about using StringBuffer's setLength() on the char array? Is that the same as padding with spaces?
 
Terry Martinson
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe - I don't know if the setLength() method is the same as padding with spaces.
Seid -
I read that post but was not sure what this meant:
"a) The file is valid. You've just used the maximum length of the field by padding with spaces and I should do the same. i.e. You are are trying to simulate typical semi-clueless customers, who says one thing but actually means something else. "

My take on the above is that Gareth was referring to Sun when he said "You". So, he's saying that you/Sun has used the max lenghth of field by padding with spaces and I/Gareth should do the same.
Here a small method I use to pad a particular data string.

TJ
 
Seid Myadiyev
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Terry, thank you very much for your clarification!
Seid
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic