I'm executing java code. readLine()
method returns an empty string from a text file even when there is text in the file.
BufferedReader csv = new BufferedReader(new FileReader("D:/SentiWordNet_3.0.0/home/swn/www/admin/dump/senti.txt"));
String line = "";
while((line = csv.readLine()) != null){
String[] data = line.split("\t");
Double score = Double.parseDouble(data[2])-Double.parseDouble(data[3]);
}
After the split()
is called, there is an exception thrown Arrayindexoutofboundsexception
.
Below is the text file. Each line starts with "a"
followed by a number. the code was able to retrieve the line with the word apocrine, but not the line with word eccrine. when I ran in debug mode, the line variable returned as empty string.
a 00098529 0 0 apocrine#1 (of exocrine glands) producing a secretion in which part of the secreting cell is released with the secretion; "mother's milk is one apocrine secretion"
a 00098736 0.25 0 eccrine#1 (of exocrine glands) producing a clear aqueous secretion without releasing part of the secreting cell; important in regulating body temperature
a 00098933 0 0 artesian#1 (of water) rising to the surface under internal hydrostatic pressure; "an artesian well"; "artesian pressure"
Should I use someother construct to read the lines from the text file