I am having this code in Java to read from a file and pass the values to a vector but it seems not to consider the last line.
int lines = 0;
Vector<String> vc = new Vector<String>();
BufferedReader in = new BufferedReader(new FileReader(FILE_NAME));
while(in.readLine() != null){
if(lines >= 1){
vc.addElement(in.readLine());
}
lines++;
}
System.out.println(vc.size());
for(int i = 0; i< vc.size(); i++){
System.out.println(vc.get(i));
}
The elements of a file are
4
fdgdfs
sdfg
sdfg
sfdg
sdfg
for example and I want to read from the second line and add them in the vector. The results printing are
3
sdfg
sfdg
null
What seems to be the problem?