arm-linux

http://armboard.taobao.com/

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

QFile本身有copy函数,在这里使用QTextStream实现一下。

 

QFile sourceFile("test.txt");

QFile targetFile("readtext.txt");

 

if(sourceFile.open(QIODevice::ReadOnly | QIODevice::Truncate)&
           targetFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
        {
        QTextStream in(&sourceFile);
        QTextStream out(&targetFile);                 
                   out<<in.readAll(); //用readAll()实现

 

                   //while ( !in.atEnd() ) {
                   //  out<<in.readLine()<<"/n";
                   // } 用readLine()实现

       }

sourceFile.close();

targetFile.close();

posted on 2010-05-13 15:30  arm-linux  阅读(399)  评论(0编辑  收藏  举报