<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://95.179.246.60/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Read_a_file_line_by_line</id>
	<title>Read a file line by line - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://95.179.246.60/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Read_a_file_line_by_line"/>
	<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Read_a_file_line_by_line&amp;action=history"/>
	<updated>2026-05-08T12:45:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>http://95.179.246.60/mediawiki/index.php?title=Read_a_file_line_by_line&amp;diff=100&amp;oldid=prev</id>
		<title>Nmingott: imported material</title>
		<link rel="alternate" type="text/html" href="http://95.179.246.60/mediawiki/index.php?title=Read_a_file_line_by_line&amp;diff=100&amp;oldid=prev"/>
		<updated>2025-05-04T20:33:55Z</updated>

		<summary type="html">&lt;p&gt;imported material&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Problem&amp;#039;&amp;#039;&amp;#039;. Unix/Linux systems are heavily based in text files. In particular, a record in a Unix file is identified by a text line, which is a character sequence ending with LineFeed. We would like to read lines from a text file, for example a log file, what is the right way to do it? Consider always the log writing process can happen anytime, even when we are reading and  we can&amp;#039;t assume we have permission to lock the file when we are reading from it.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Solution&amp;#039;&amp;#039;&amp;#039;. In the week ending 22-Oct-2021 I [NM] tried to use the &amp;lt;code&amp;gt;StandardFileStream&amp;gt;&amp;gt;upTo:&amp;lt;/code&amp;gt; method. It was a disaster. This method does not do what we want out of the box and it is in the ANSI standard, it is not a good idea to change it. We added a new method to Cuis to cope with this task on 27-Oct. See &amp;lt;code&amp;gt;StandardFileStream&amp;gt;&amp;gt;upTo:delimiterIsTerminator:&amp;lt;/code&amp;gt;. When &amp;lt;code&amp;gt;delimiterIsTerminator&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; the method is perfect for reading log files and makes the task very easy and error free. Please see the test methods in package &amp;lt;code&amp;gt;BaseImageTests&amp;lt;/code&amp;gt; for further details and comments.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Example-1&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 &amp;quot; . create a file near the Image for tests and put in a fist line &amp;quot;&lt;br /&gt;
 fw _ &amp;#039;tmp.txt&amp;#039; asFileEntry . &lt;br /&gt;
 fw fileContents: &amp;#039;line-1&amp;#039;, (Character lf) asString . &lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;. open the reader stream and read up to when you find something &amp;quot;&lt;br /&gt;
 rs _ &amp;#039;tmp.txt&amp;#039; asFileEntry readStream.&lt;br /&gt;
 rs upTo: (Character newLineCharacter) delimiterIsTerminator: true.  &amp;quot;=&amp;gt; &amp;#039;line-1&lt;br /&gt;
 &amp;#039; &amp;quot;&lt;br /&gt;
 rs upTo: (Character newLineCharacter) delimiterIsTerminator: true.  &amp;quot;=&amp;gt; nil &amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;. add a line to the file &amp;quot;&lt;br /&gt;
 fw appendContents: &amp;#039;line-2&amp;#039;, (Character lf) asString .&lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;. and you will get it in the reader stream &amp;quot;&lt;br /&gt;
 rs upTo: (Character newLineCharacter) delimiterIsTerminator: true.  &amp;quot;=&amp;gt; &amp;#039;line-2&lt;br /&gt;
 &amp;#039; &amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;. remember to close the stream &amp;quot;&lt;br /&gt;
 rs close. &lt;br /&gt;
----Dr. Nicola Mingotti started this page on 22-Oct-2021. Last updated 27-Oct-2021.&lt;/div&gt;</summary>
		<author><name>Nmingott</name></author>
	</entry>
</feed>