• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Some questions about SCJD...Who can help me?

 
HaoZhe Xu
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.in the data file what method should I use to read the numeric value?
readInt readShort etc or just readByte and change it into specific value
e.g.
int magicCookie = dbFile.readInt();
or:
byte magicCookieByte = new byte [2];
dbFile.read(magicCookieByte);
magicCookie = (int)magicCookie[0] * 16 + (int)magicCookieByte[1];
???
2.in a non-network mode, program loads a local datafile, after the user did several operations and exit, should the program save all the change?
3.server should be able to accept more than one clients, so should the server use only one RandomAccessFile object and share it with all the clients threads or give each client thread a new object?
4.in my root directory, the structure is [root]/suncertify/db/,in db directory,there is some class, in the top of those classes, I wrote package suncertify.db,where should I compile those classes? In the root using javac suncertify/db/xXX.java or in the db directory?
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi HaoZhe,
1. int magicCookie = dbFile.readInt();
2. Changes should be saved continuously, not just when the app exists.
3. IMO, it's easier to have only one RAF/FileChannel instance and some synchronization on it.
4. I would put my class files ... where I feel it handy to have them. It may be anywhere.
Best,
Phil.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic