View source code
							
							
						
								Display the source code in std/stdio.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Function std.stdio.File.byLine
Returns an input range set up to read from the file handle one line at a time.
						
				auto byLine(Terminator, Char)
				(
				
				  KeepTerminator keepTerminator = No
				  Terminator terminator = '\n'
				
				)
				
				if (isScalarType!Terminator);
				
				
				auto byLine(Terminator, Char)
				(
				
				  KeepTerminator keepTerminator,
				
				  Terminator terminator
				
				)
				
				if (is(immutable(ElementEncodingType!Terminator) == immutable(Char)));
						
					
				The element type for the range will be Char[]. Range primitives
may throw StdioException on I/O error.
Note
Each front will not persist after popFront is called, so the caller must copy its contents (e.g. by
calling to!string) when retention is needed. If the caller needs
to retain a copy of every line, use the byLineCopy function
instead.
Parameters
| Name | Description | 
|---|---|
| Char | Character type for each line, defaulting to char. | 
| keepTerminator | Use Yesto include the
terminator at the end of each line. | 
| terminator | Line separator ( '\n'by default). Usenewlinefor portability (unless the file was opened in
text mode). | 
Example
import stdExample
import stdNotice that neither example accesses the line data returned by
front after the corresponding popFront call is made (because
the contents may well have changed).
Authors
Walter Bright, Andrei Alexandrescu, Alex Rønne Petersen
License
					Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.