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
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
+ 1
Working with Files Getting File Info
question-2/2
if File.readable? ("demo.txt")
File.read ("demo.txt")
end