File input/output: Difference between revisions

Content added Content deleted
Line 553:
 
Also, abort" can be used instead of throw if desired.
 
=={{header|Fortran}}==
{{works with|Fortran|2003}}
{{works with|gfortran|4.3.2}}
 
It uses the <tt>access="stream"</tt> which is defined in Fortran 2003 standard and should allow to "copy" also binary data easily.
 
<lang fortran>program FileIO
 
integer, parameter :: out = 123, in = 124
integer :: err
character(len=1) :: c
 
open(out, file="output.txt", status="new", action="write", access="stream", iostat=err)
if ( err == 0 ) then
open(in, file="input.txt", status="old", action="read", access="stream", iostat=err)
if ( err == 0 ) then
err = 0
do while ( err == 0 )
read(unit=in, iostat=err) c
if ( err == 0 ) write(out) c
end do
close(in)
end if
close(out)
end if
 
end program FileIO</lang>
 
=={{header|Groovy}}==