mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-08 15:52:26 +01:00
created 15.12 documentation branch
git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1492 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
52
documentation/15.12/eiffel/Examples/example-file-io.wiki
Normal file
52
documentation/15.12/eiffel/Examples/example-file-io.wiki
Normal file
@@ -0,0 +1,52 @@
|
||||
[[Property:title|Example: File IO]]
|
||||
[[Property:weight|0]]
|
||||
[[Property:uuid|b26aa8e3-5963-94ae-b523-642c8b79637b]]
|
||||
==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
|
||||
input_file.read_character
|
||||
until
|
||||
input_file.exhausted
|
||||
loop
|
||||
output_file.put (input_file.last_character)
|
||||
input_file.read_character
|
||||
end
|
||||
|
||||
input_file.close
|
||||
output_file.close
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
input_file: PLAIN_TEXT_FILE
|
||||
output_file: PLAIN_TEXT_FILE
|
||||
|
||||
end
|
||||
</code>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user