File IO from Ruby

Asked 2 years ago, Updated 2 years ago, 62 views

You want to read the file from the DB and save it in the .txt file.

Please tell me how to type in the file in Ruby

file-io ruby

2022-09-22 15:33

1 Answers

Open the file with :open in File class

:write in IO class.

File.open("/purpose/path/text.txt", 'w') { | file| file.write("content")}

For shorter

File.write('/path/to/file', 'Some glorious content')

It can be written as .


2022-09-22 15:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.