Home
Ruby
ActiveRecord
Array
CGI
Class
Collections
Database
Date
Design Patterns
Development
File Directory
GUI
Hash
Language Basics
Method
Network
Number
Rails
Range
Reflection
Statement
String
Threads
Time
Tk
Unit Test
Windows Platform
XML
Menu
File.open : File.new « File Directory « Ruby
Ruby
File Directory
File.new
File.open
file2 = File.open(
"C:\\Ruby\\Sample"
){|f| puts
"The file object is #{f}"
} puts file2
Related examples in the same category
1.
File Modes Usable with File.new
2.
Using the append mode to create a program that appends a line of text to a file each time it's run:
3.
File.new creates a new object of the class File using the method new.
4.
You need to specify the full path for the file unless the file is in the current working directory.