<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[If we have large text file, which class object we can use to store all the contents of the file temporarily?]]></title><description><![CDATA[<p dir="auto">Suppose my code is @<br />
QFile file(":/file");<br />
file.open (QIODevice::ReadOnly);<br />
? = file.readAll ();<br />
@</p>
]]></description><link>https://forum.qt.io/topic/11995/if-we-have-large-text-file-which-class-object-we-can-use-to-store-all-the-contents-of-the-file-temporarily</link><generator>RSS for Node</generator><lastBuildDate>Sun, 07 Jun 2026 10:30:35 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/11995.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Dec 2011 08:59:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to If we have large text file, which class object we can use to store all the contents of the file temporarily? on Wed, 07 Dec 2011 11:29:21 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="Andre" date="1323256622"]Yes.<br />
Should be simple enough if you use a line-by-line parsing of your file. Did you try to create an implementation for that yet? Running into any specific issues?[/quote]</p>
<p dir="auto">Ya i have checked reading line by line  to  find some specific data it is working fine further i am trying some other operation on the data which i need.</p>
]]></description><link>https://forum.qt.io/post/119589</link><guid isPermaLink="true">https://forum.qt.io/post/119589</guid><dc:creator><![CDATA[pratik041]]></dc:creator><pubDate>Wed, 07 Dec 2011 11:29:21 GMT</pubDate></item><item><title><![CDATA[Reply to If we have large text file, which class object we can use to store all the contents of the file temporarily? on Wed, 07 Dec 2011 11:17:02 GMT]]></title><description><![CDATA[<p dir="auto">Yes.<br />
Should be simple enough if you use a line-by-line parsing of your file. Did you try to create an implementation for that yet? Running into any specific issues?</p>
]]></description><link>https://forum.qt.io/post/119587</link><guid isPermaLink="true">https://forum.qt.io/post/119587</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Wed, 07 Dec 2011 11:17:02 GMT</pubDate></item><item><title><![CDATA[Reply to If we have large text file, which class object we can use to store all the contents of the file temporarily? on Wed, 07 Dec 2011 10:14:12 GMT]]></title><description><![CDATA[<p dir="auto">my file is something like this</p>
<p dir="auto">@<br />
.......................................<br />
.......................................<br />
.......................................<br />
IDDLG_LOGIN OFI_DIALOGEX<br />
BEGIN<br />
...........................<br />
........................<br />
END<br />
...........................<br />
.............................<br />
.<br />
IDDLG_CONFIRM_OFI_DIALOGEX<br />
BEGIN<br />
...........................<br />
...............................<br />
END<br />
.<br />
.<br />
@<br />
Here suppose i have to find the text "IDDLG_LOGIN OFI_DIALOGEX" .<br />
After that i have to do some string operation starting "BEGIN"  to "END".<br />
.</p>
]]></description><link>https://forum.qt.io/post/119575</link><guid isPermaLink="true">https://forum.qt.io/post/119575</guid><dc:creator><![CDATA[pratik041]]></dc:creator><pubDate>Wed, 07 Dec 2011 10:14:12 GMT</pubDate></item><item><title><![CDATA[Reply to If we have large text file, which class object we can use to store all the contents of the file temporarily? on Wed, 07 Dec 2011 09:59:41 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="pratik041" date="1323251808"]So is reading line by line and stopping where i find the required data would be a better idea? [/quote]</p>
<p dir="auto">If your aim is just to "grep" the file, yes. In the case the file is 2000 lines long and the word or data you are searching is in the first 10 lines you will avoid scanning all the other 1990 remaining lines. In the worst case, you data is at the end of the file and you will have to scan the whole.<br />
By the way, the file is a resource, so aren't you already sure about its content?</p>
]]></description><link>https://forum.qt.io/post/119570</link><guid isPermaLink="true">https://forum.qt.io/post/119570</guid><dc:creator><![CDATA[fluca1978]]></dc:creator><pubDate>Wed, 07 Dec 2011 09:59:41 GMT</pubDate></item><item><title><![CDATA[Reply to If we have large text file, which class object we can use to store all the contents of the file temporarily? on Wed, 07 Dec 2011 09:56:48 GMT]]></title><description><![CDATA[<p dir="auto">So is reading line by line and stopping where i find the required data would be a better idea?</p>
]]></description><link>https://forum.qt.io/post/119569</link><guid isPermaLink="true">https://forum.qt.io/post/119569</guid><dc:creator><![CDATA[pratik041]]></dc:creator><pubDate>Wed, 07 Dec 2011 09:56:48 GMT</pubDate></item><item><title><![CDATA[Reply to If we have large text file, which class object we can use to store all the contents of the file temporarily? on Wed, 07 Dec 2011 09:50:48 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="pratik041" date="1323251213"]<br />
I want to keep all its (large) contents into memory because  i want to search a specific data present in the file or  not. Is their any other way of doing this without storing all the contents into the memory.[/quote]<br />
Sure there is!<br />
You can just scan through the file bit by bit. That will be quite fast, as the file is actually in memory already (it is a resource, after all).</p>
]]></description><link>https://forum.qt.io/post/119568</link><guid isPermaLink="true">https://forum.qt.io/post/119568</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Wed, 07 Dec 2011 09:50:48 GMT</pubDate></item><item><title><![CDATA[Reply to If we have large text file, which class object we can use to store all the contents of the file temporarily? on Wed, 07 Dec 2011 09:48:43 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="Andre" date="1323250299"]Question is: why? The file is probably not going anywhere in the meantime, so why do want to keep all its (large) contents into memory? [/quote]</p>
<p dir="auto">Agree!<br />
I suspect you are going to scan/analyze the file content, and I guess it can be done iterating thru the content of the file instead of loading all the file into memory. With a few more details we could help you in achieving your aim.</p>
]]></description><link>https://forum.qt.io/post/119566</link><guid isPermaLink="true">https://forum.qt.io/post/119566</guid><dc:creator><![CDATA[fluca1978]]></dc:creator><pubDate>Wed, 07 Dec 2011 09:48:43 GMT</pubDate></item><item><title><![CDATA[Reply to If we have large text file, which class object we can use to store all the contents of the file temporarily? on Wed, 07 Dec 2011 09:46:53 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="Andre" date="1323250299"]"store"? Store where? In memory? On disc? On the cloud perhaps?<br />
And what is "temporarily"? For the runtime of your application, or for some longer period of time?</p>
<p dir="auto">Judging by your code fragment, I think you want to store the contents in-memory. Question is: why? The file is probably not going anywhere in the meantime, so why do want to keep all its (large) contents into memory? If you really need to, I guess QByteArray is the most efficient class to do it with. At least it won't use UTF-16 if the original file was ASCII or UTF-8 or some other 8-bit encoding. That should save you memory.</p>
<p dir="auto">Another side note is: you already <em>have</em> the file in memory, because you are reading from a resource. Why do you insist in keeping <em>another</em> copy of the same file in memory too?[/quote]</p>
<p dir="auto">I want to keep all its (large) contents into memory because  i want to search a specific data present in the file or  not. Is their any other way of doing this without storing all the contents into the memory.</p>
]]></description><link>https://forum.qt.io/post/119565</link><guid isPermaLink="true">https://forum.qt.io/post/119565</guid><dc:creator><![CDATA[pratik041]]></dc:creator><pubDate>Wed, 07 Dec 2011 09:46:53 GMT</pubDate></item><item><title><![CDATA[Reply to If we have large text file, which class object we can use to store all the contents of the file temporarily? on Wed, 07 Dec 2011 09:31:39 GMT]]></title><description><![CDATA[<p dir="auto">"store"? Store where? In memory? On disc? On the cloud perhaps?<br />
And what is "temporarily"? For the runtime of your application, or for some longer period of time?</p>
<p dir="auto">Judging by your code fragment, I think you want to store the contents in-memory. Question is: why? The file is probably not going anywhere in the meantime, so why do want to keep all its (large) contents into memory? If you really need to, I guess QByteArray is the most efficient class to do it with. At least it won't use UTF-16 if the original file was ASCII or UTF-8 or some other 8-bit encoding. That should save you memory.</p>
<p dir="auto">Another side note is: you already <em>have</em> the file in memory, because you are reading from a resource. Why do you insist in keeping <em>another</em> copy of the same file in memory too?</p>
]]></description><link>https://forum.qt.io/post/119558</link><guid isPermaLink="true">https://forum.qt.io/post/119558</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Wed, 07 Dec 2011 09:31:39 GMT</pubDate></item><item><title><![CDATA[Reply to If we have large text file, which class object we can use to store all the contents of the file temporarily? on Wed, 07 Dec 2011 09:13:59 GMT]]></title><description><![CDATA[<p dir="auto">or you can use "QTemporaryFile":<a href="http://doc.qt.nokia.com/latest/qtemporaryfile.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.nokia.com/latest/qtemporaryfile.html</a></p>
]]></description><link>https://forum.qt.io/post/119550</link><guid isPermaLink="true">https://forum.qt.io/post/119550</guid><dc:creator><![CDATA[Rahul Das]]></dc:creator><pubDate>Wed, 07 Dec 2011 09:13:59 GMT</pubDate></item><item><title><![CDATA[Reply to If we have large text file, which class object we can use to store all the contents of the file temporarily? on Wed, 07 Dec 2011 09:11:48 GMT]]></title><description><![CDATA[<p dir="auto">any text compatible container class will do more or less, different containers have different functionality, suitable for different usage scenarios, which you didn't specify</p>
]]></description><link>https://forum.qt.io/post/119551</link><guid isPermaLink="true">https://forum.qt.io/post/119551</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 07 Dec 2011 09:11:48 GMT</pubDate></item><item><title><![CDATA[Reply to If we have large text file, which class object we can use to store all the contents of the file temporarily? on Wed, 07 Dec 2011 09:05:10 GMT]]></title><description><![CDATA[<p dir="auto">QByteArray , i suppose.</p>
]]></description><link>https://forum.qt.io/post/119549</link><guid isPermaLink="true">https://forum.qt.io/post/119549</guid><dc:creator><![CDATA[Rahul Das]]></dc:creator><pubDate>Wed, 07 Dec 2011 09:05:10 GMT</pubDate></item></channel></rss>