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

URLyBIRD update, insert record

 
Patrick McDonogh
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all ya ranchers. I would just like to say thanks for helping me pass the Programmer assignment, 85%.

I am now doing the developer assignment, and have a couple of questions.

1) In the data java file should i have a copy of the database.db file, for example arrays representing the file that i update aswell as the file. So i load the array representation of the file when i start the program and update the file and array representation as the data changes.

Also is there a way to write bytes (either insert or overrite) at a specific point in the database.db file. There reason i ask is i am using a DataOutputStream and when i write a byte[] to the file it overrites all the information previously in the file. Surely to make a small change to a file for example, if the file is:

line1
line2
line3

and i wanted to change it to

line1
line4
line3

i wouldnt have to read in all the bytes using a DataInputStream and change the data and then use a DataOutputStream to write the changes bytes back into the file.

Thanks a lot for all your help and sorry for the long question.
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Patrick and welcome!


1) In the data java file should i have a copy of the database.db file, for example arrays representing the file that i update aswell as the file. So i load the array representation of the file when i start the program and update the file and array representation as the data changes.


This you are thinking about is known as a "cache". There are a lot of post in the forum about it.


There reason i ask is i am using a DataOutputStream and when i write a byte[] to the file it overrites all the information previously in the file ...


Umm random access to the file would be perfect...
Take a look to IO package

Regards, Ori
 
Patrick McDonogh
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou for the reply, its amazing how after reading a couple of comments things become far more clear.
 
Jeff Haynes
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMHO - if the directions say that the data is in a particular format(DataInputStream,DataOutputStream) then you aren't necessarily required to use these Classes. You simply need to make sure that when you write the data out to the file its in the same format.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic