How do keep track of line numbers when reading a file with a stream?
You could use the class java.io.LineNumberInputStream but this class is deprecated since it incorrectly assumes that bytes represent characters. Instead, use the class LineNumberReader as described in the question How do keep track of line numbers when reading a file with a Reader?
Further Information
Author of answer: Joris Van den Bogaert