Hi all, I have a rather stupid question to ask: How to read the properties file as plain text?
I use RandomAccessFile to read and update (if users want to change it). My file looks like this:
local dir data
local file db-1x1.db
server address 127.0.0.1
server port 1099
server dir data
server file db-1x1.db
I use while loop to check if raf.readLine() contains "local" or "server" and assign the corresponding variables to the File constructor.
Now my problem is the position of these lines. If I put the "local" lines first and run the stand-alone version, everything goes well. Now without changing the file or code, I run the network version, I get "null" for the file. If i include lines 2-6 in the code, running the network version I get NullPointerException on the 2nd while line (line 7).
Similarly if I put the server lines first then the local lines in the properties file, and run the standalone version, I get null. When lines 2-6 included, I get NullPointerException.
Can someone please help why I get NullPointerException when lines2-6 code are included? This set of code hopes to cater I don't have to start reading on line 1 (position 0) of the file.