method

new

v1_8_7_330 - Show latest stable - Class: File
new(...)
public

Opens the file named by filename according to mode (default is “r”) and returns a new File object. See the description of class IO for a description of mode. The file mode may optionally be specified as a Fixnum by or-ing together the flags (O_RDONLY etc, again described under IO). Optional permission bits may be given in perm. These mode and permission bits are platform dependent; on Unix systems, see open(2) for details.

f = File.new("testfile", "r")
f = File.new("newfile",  "w+")
f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)

2Notes

Errors Raised

sshaw · Apr 21, 2010

Modes listed in IO class

webmat · Feb 23, 2013

See class IO for file open modes