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

Help with SCJD.

 
Krishna Revuru
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gurus,
I took my SCJP a few months back and I would call myself a junior level Java Programmer.
I downloaded my SCJD Assignment a week ago. And I want some help trying to understand it. I went through the requirements couple of times. I thought I sort of got a hang of what the Assignment was all about.
Then as a starting step tried to program to read the data contents into my Program and view it. But I am unable to read the 2 byte, 32 bits, 6 bits values that are present in the db-2x1.db file.
Q1. Can someone help me?
Q2. Can someone walk me through as to how I am supposed to approach the assignment?
Q3. Is there someone I can join with to do my SCJD?
Thanks in advance.
Krishna
 
Bob Reeves
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Krishna:
Look at RandomAccessFile. You can use methods like
readShort, ReadInt, readLong. (The io package.)
Also, look at FileChannel and the read(ByteBuffer) method. (The nio.channels package.)
These work perfectly on the assignment database.
Tx
 
Krishna Revuru
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Bob,
I am looking at the NIO APi now. And I will take it up from here.
Do you by any chance have any sample code that you can pass on to me?
Thx in advance.
Krishna
 
Bob Reeves
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Krishna:
It's quite simple to use RandomAccessFile. Here is my code to read the DB's magic number and record length field , which may or may not be part of your database. The variable db (a method argument) contains the full pathname of the database.
String fileName = db;
RandomAccessFile raFile = new RandomAccessFile(new File(fileName), "rwd");

// skip over Magic Cookie and Overall lenght each record
raFile.readInt();
int recordLength = raFile.readInt();
Tx
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic