Your use of the
delimiter
setting means that newlines will not be treated as token separators. Also the
break
statement terminates the loop, which may not be what you want. The code should be something like:
Scanner s = new Scanner(fin);
int lineNum;
String A ;
for(lineNum=1; s.hasNext(); lineNum++) {
A=s.next();
if(!A.contains("//")){
al.add(A);
}
else {
s.nextLine();
}
}
Using
nextLine
, as above, ensures that the loop continues to the end of the file.