mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-07 23:32:42 +01:00
Created.
Author:halw Date:2011-01-21T03:06:47.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@741 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
50
documentation/current/examples/example-file-io.wiki
Normal file
50
documentation/current/examples/example-file-io.wiki
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
[[Property:title|File IO]]
|
||||||
|
[[Property:link_title|Example: File IO]]
|
||||||
|
[[Property:weight|0]]
|
||||||
|
[[Property:uuid|c6dda104-bd09-a00d-58b5-0d536e95d0c1]]
|
||||||
|
==Description==
|
||||||
|
|
||||||
|
Create a file "output.txt" containing the contents of "input.txt".
|
||||||
|
|
||||||
|
|
||||||
|
==Source==
|
||||||
|
|
||||||
|
Problem description from [http://rosettacode.org/wiki/File_IO Rosetta Code: File IO]
|
||||||
|
|
||||||
|
==Solution==
|
||||||
|
|
||||||
|
<code>
|
||||||
|
class
|
||||||
|
APPLICATION
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make
|
||||||
|
-- Run application.
|
||||||
|
do
|
||||||
|
create input_file.make_open_read ("input.txt")
|
||||||
|
create output_file.make_open_write ("output.txt")
|
||||||
|
from
|
||||||
|
|
||||||
|
until
|
||||||
|
input_file.exhausted
|
||||||
|
loop
|
||||||
|
input_file.read_line
|
||||||
|
output_file.put_string (input_file.last_string)
|
||||||
|
output_file.new_line
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
input_file: PLAIN_TEXT_FILE
|
||||||
|
output_file: PLAIN_TEXT_FILE
|
||||||
|
|
||||||
|
end
|
||||||
|
</code>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user