How to count number of rows in a textinputstream


before iterating through a textinputstream until eof,I need to determine the number of rows in that textinputstream.

How to do this?


Read the textinputstream in one go if it’s not too large and then do a split with EndOfLine as delimiter. The unbound of the resulting array is what you want.


using CountFields will consume less memory… unless you DO need the data split into an array

What about an empty line in the text (one that is not at the end of the text, but it can be) ?

It will still be seen because the split is based on EndOfLine, not the length of lines.

That is what I think. On the other way, if the programmer does not add a Row for empty lines…