0

RE: Working With Files Deleting Files

Fill in the blanks to open a file and output its contents if the file exists. Otherwise, output the corresponding error message. File. ("demo.txt") f = File.open("demo.txt", "r") puts f. .close puts "File does not exist" end

23rd Nov 2016, 12:33 AM
Miles Griffith
Miles Griffith - avatar
2 Antworten
+ 3
please tag your question with the appropriate language, in this case ruby if File.file?("demo.txt") f=File.open("demo.txt", "r") puts f.read f.close else puts "File does not exist" end
23rd Nov 2016, 5:42 AM
Rill Chritty
Rill Chritty - avatar
+ 1
Working with Files Getting File Info question-2/2 if File.readable? ("demo.txt") File.read ("demo.txt") end
2nd Dec 2016, 4:38 PM
Resit Usta