c++builder 读写文件类
TStreamReader、TStreamWriter
读取一行
http://docwiki.embarcadero.com/CodeExamples/XE8/en/StreamCharRdWr_%28C%2B%2B%29
void __fastcall TMainForm::btSaveClick(TObject *Sender) { TStreamWriter* writer; /* Create a new stream writer directly. */ writer = new TStreamWriter("local_file.txt", false, TEncoding::UTF8, 1024); /* Store the title and then the text. */ writer->WriteLine(edtTitle->Text); writer->Write(mmText->Text); /* Close and Free the writer. */ delete writer; } void __fastcall TMainForm::btLoadClick(TObject *Sender) { TStreamReader* reader; /* Create a new stream writer directly. */ reader = new TStreamReader("local_file.txt", TEncoding::UTF8); /* Read the title and then the actual text. */ edtTitle->Text = reader->ReadLine(); mmText->Text = reader->ReadToEnd(); /* Close and Free the writer. */ delete reader; }
TStringReader、
TStringWriter