I'm using a common way to read text file in java:
public String readIndex() throws IOException{
if(!fileExisits)
return "";
String indexInFile = "";
while((indexInFile = reader.readLine())!=null){
indexInFile += reader.readLine();
System.out.println("indexxxxxxxx: " + indexInFile);
}
System.out.println("reader get: " + indexInFile);
return indexInFile;
}
and the output is : is file :: true
indexxxxxxxx: 1fefefe\fefeef
indexxxxxxxx: effe
indexxxxxxxx: effe
indexxxxxxxx: null
reader get: null
null
as you can see in the last line the output String indexInFile is being set to null.
my reader is:
reader = new BufferedReader(new FileReader(fileName));
any suggestions why it happens? hopes that I write all the relevant code.