//文件的读取
QFile file_1("C:\Users\L\Desktop\1617.txt");
QVector<int> array;
if(file_1.open(QIODevice::ReadOnly))
{
QTextStream stream(&file_1);
while(!file_1.atEnd())
{
int buf;
QStringList list = stream.readAll().split(" ");
QListIterator<QString> li(list);
while(li.hasNext())
{
buf=li.next().toInt();
array.append(buf);
}
}
}
//文件的写入
QFile file_2("C:\Users\L\Desktop\1618.txt");
if(file_2.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream out(&file_2);
for(int a{0}; a<array.size(); a++)
out<<array[a]<<" ";
}
file_2.close();