I have a file, let's call it text.txt. It contains a few lines of text. I am trying to read this in with my code so that I can edit it using my code, unfortunately whenever I try and read it, it simply returns null, and does not load the code at all. No error message or anything.
An example is a file with the following in it :
a
b
c
d
e
f
when loaded, it loads the following :
a
b
c
d
null
Which makes no sense to me whatsoever, since, if it is entering the while loop, it shouldn't be exiting! Can anyone help me out please ?
try
{
File theFile = new File(docName);
if (theFile.exists() && theFile.canRead())
{
BufferedReader docFile;
docFile = new BufferedReader(
new FileReader(f));
String aLine = docFile.readLine();
while (aLine != null)
{
aLine = docFile.readLine();
doc.add( aLine );
}
docFile.close();
}