Ruby Language File and I/O Operations

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Parameters

FlagMeaning
"r"Read-only, starts at beginning of file (default mode).
"r+"Read-write, starts at beginning of file.
"w"Write-only, truncates existing file to zero length or creates a new file for writing.
"w+"Read-write, truncates existing file to zero length or creates a new file for reading and writing.
"a"Write-only, starts at end of file if file exists, otherwise creates a new file for writing.
"a+"Read-write, starts at end of file if file exists, otherwise creates a new file for reading and writing.
"b"Binary file mode. Suppresses EOL <-> CRLF conversion on Windows. And sets external encoding to ASCII-8BIT unless explicitly specified. (This flag may only appear in conjunction with the above flags. For example, File.new("test.txt", "rb") would open test.txt in read-only mode as a binary file.)
"t"Text file mode. (This flag may only appear in conjunction with the above flags. For example, File.new("test.txt", "wt") would open test.txt in write-only mode as a text file.)


Got any Ruby Language Question?