RosettaCodeData/Task/File-input-output/Ada/file-input-output-3.ada

27 lines
721 B
Ada
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
with Ada.Sequential_IO;
procedure Read_And_Write_File_Character_By_Character is
package Char_IO is new Ada.Sequential_IO (Character);
use Char_IO;
Input, Output : File_Type;
Buffer : Character;
begin
Open (File => Input, Mode => In_File, Name => "input.txt");
Create (File => Output, Mode => Out_File, Name => "output.txt");
loop
Read (File => Input, Item => Buffer);
Write (File => Output, Item => Buffer);
end loop;
2015-02-20 09:02:09 -05:00
Close (Input);
Close (Output);
2013-04-10 21:29:02 -07:00
exception
when End_Error =>
2015-02-20 09:02:09 -05:00
if Is_Open(Input) then
Close (Input);
end if;
if Is_Open(Output) then
Close (Output);
end if;
2013-04-10 21:29:02 -07:00
end Read_And_Write_File_Character_By_Character;