Hi Raj,
If you completed your project, I wouldn't change that now. I guess that everything works, so why taking any risk in such a refactoring?
Opening/closing the file connection for each access is what Max himself does in his great SCJD book. It's highly defendable because - as you state yourself - performance is not a requirement in this assignment.
Honestly, it's even better if you don't change anything. Your solution is slow (but it's not an issue) but scalable (a quality). If you don't use NIO (and there are now compelling reasons to not choose NIO
), and wants to keep your design simple, you'll have to keep one connection open per client, which is not scalable at all (remember that RAF is not threadsafe). An alternate solution would be to implement a RAF connections pool, but I think it's out of scope of this assignment (though I'm now experimenting it, just for the fun
).
Regards,
Phil.