Read a file line by line: Difference between revisions

m
(Undo revision 109928 by Agspathis (talk))
Line 470:
=={{header|J}}==
 
J currently discourages this "read just one line" approach. In addition to the arbitrary character of lines, there are issues of problem size and scope (what x happens when you have a billion characters between your newline delimiters?). Usually, it's easier to just read the entire file, or memory map the file, and when files are so large that that is not practical it's probably better to put the programmer in explicit control of issues like block sizes and exception handling.
 
This implementation looks for lines separated by ascii character 10. Lines returned here do not include the line separater character. Files with no line-separating character at the end are treated as well formed -- if the last character of the file is the line separator that means that you have an empty line at the end of the file.
6,962

edits