• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Database file, I/O of Records

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys, I really need help on this.

I'm trying to make a start on my assignment, by implementing the Database Interface that was provided to me, but I'm getting a bit confused here, my db.db file is in binary format, and as far as I know, I can read and write from text files in text format, so what am I meant to do?? am I supposed to write some sort of function that translates text <=> binary, or is there some sort of standard Java I/O facility that allows me to do that? I'm sure it's something easy but I'm lost here...
 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jay,

is there some sort of standard Java I/O facility that allows me to do that?


Yes. Most likely the database is written using output stream and input stream which uses byes not strings. Read your instructions to be sure.
You can use any sub-class of InputStream and OutputStream to manipulate your data, or you can use the widely used RandomAccessFile. All of the previous classes have functions to read bytes.
 
M Jay
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you mate, that was helpful. I guess I need to research for a bit on JAVA I/O APIs, is this the right place to start or should I start doing something else like the GUI
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jay,
I think you starting in the right place. IMO, the GUI is the last part to do. I used MVC pattern to do the project. one should get the model working first, without any gui. Then you can start building the network layer, the controler, and when everything is working you can build your gui. This way you will seperate between the presentation layer and your business logic.

However, I didn't follow the previouse steps strictly. At the time of doing my project, I didn't have experiece with RMI. So, I build the project without networking support, then I added the network layer. It was easier for me this way.
 
M Jay
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cool, sound the best way to do it... where could I get more info regarding MVC, website or something... Many thanks by the way
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jay,
If you search the web for MVC, you will find may usefull resources.
Here is a link I used to undersatand some common design patterns.
web page
 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by M Jay:
Guys, I really need help on this.

I'm trying to make a start on my assignment, by implementing the Database Interface that was provided to me, but I'm getting a bit confused here, my db.db file is in binary format, and as far as I know, I can read and write from text files in text format, so what am I meant to do?? am I supposed to write some sort of function that translates text <=> binary, or is there some sort of standard Java I/O facility that allows me to do that? I'm sure it's something easy but I'm lost here...



Hi, Jay. I use RandomAccessFile to read data. Then as I have read a record in (in byte form,) the following is used:




where Schema.CHARSET is "US-ASCII". Same goes for writing; I use:



Hope this helps.
 
reply
    Bookmark Topic Watch Topic
  • New Topic