建立並寫入檔案

包 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