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)
Show source
Register or log in to add new notes.
February 23, 2013
0 thanks

Modes listed in IO class

See class IO for file open modes