Open a file stream, and then retrieve each line in order with the IO method gets. : gets « File Directory « Ruby






Open a file stream, and then retrieve each line in order with the IO method gets.


file = File.new( "yourFile.txt" )
file.gets 
file.gets 

 








Related examples in the same category

1.pull out the first two lines of the example file
2.use the gets statement of the class File.