标签:tun while line pre unicode auto deb readonly pen
// 文本流
QFile file("aaa.txt");
file.open(QFileDevice::WriteOnly);
QTextStream stream(&file);
stream<<QString("hell oworld")<<123456;
file.close();
// 读取文本流
file.open(QIODevice::ReadOnly|QIODevice::Text);
stream.setAutoDetectUnicode(true);
while(!stream.atEnd()){
QString str = stream.readLine();
qDebug()<<str;
}
// 数据流
QFile file("bbb.txt");
file.open(QIODevice::WriteOnly);
QDataStream astrem(&file);
astrem<<QString("hello world")<<123456;
file.close();
file.open(QIODevice::ReadOnly);
QString str;
int num;
astrem>>str>>num;
qDebug()<<str<<num;
file.close();
标签:tun while line pre unicode auto deb readonly pen
原文地址:https://www.cnblogs.com/lodger47/p/14784705.html