Write entire file: Difference between revisions

m
Line 15:
=={{header|Ada}}==
 
<lang Ada>with Ada.Text_IO; use Ada.Text_IO;
 
procedure Write_Whole_File is
File_Name : Stringconstant String := "the_file.txt";
 
F : File_Type;
File_Name : String := "the_file.txt";
Contents: String := "(Over)write a file so that it contains a string. " &
"The reverse of Read entire file—for when you want to update or " &
"create a file which you would read in its entirety all at once.";
begin
begin
Open (F, Mode => Out_File, Name => File_Name); -- overwrite existing file
exception
when Name_Error => --Create file(F, doesMode not=> yetOut_File, existName => File_Name);
Create (F, Mode => Out_File, Name => File_Name); -- write new file
end;
 
Put (F, Contents);
Contents:Put String :=(F, "(Over)write a file so that it contains a string. " &
"The reverse of Read entire file—for when you want to update or " &
"create a file which you would read in its entirety all at once.");
Close (F);
end Write_Whole_File;</lang>
</lang>
 
=={{header|ALGOL 68}}==
Anonymous user