创建并写入文件

包 Ada.Text_IO 中的程序 Create, Put_Line ,Close 用于创建和写入文件 file.txt。

with Ada.Text_IO;

procedure Main is
   use Ada.Text_IO;
   F : File_Type;
begin
   Create (F, Out_File, "file.txt");
   Put_Line (F, "This string will be written to the file file.txt");
   Close (F);
end;

Resulting file file.txt

This string will be written to the file.txt