//文件的读取
    QFile file_1("D:\\1617.txt");
    QVector<int> intVector;
 
    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();
                intVector.append(buf);
            }
        }
    }
 
     //文件的写入
    QFile file_2("D:\\1618.txt");
    if (file_2.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        QTextStream out(&file_2);
        for (int i=0; i<intVector.size(); i++)
        {
            out << intVector[i] << " ";
        }
    }
    file_2.close();

相关文章:

  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2021-11-23
相关资源
相似解决方案