Q:

Reading text file in Qt

I want to read a huge text file in which I will be dividing the strings according to the comma (,) and store the strings in the array. So how to do this. Is there any class which does the action as StringTokenizer as in badaOS. I have tried QFile but it is not able to read whole file.

A:

QTextStream lets you read line by line
QFile file(hugeFile);
QStringList strings;
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
    QTextStream in(&file);
    while (!in.atEnd()) {
        strings += in.readLine().split(";"); 
    }
}

