Ruby/File Directory/syswrite

Материал из Wiki.crossplatform.ru

Версия от 17:57, 13 сентября 2010; ViGOur (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Save what you read to a file

fileObj = File.new ("C:\\Ruby\\customer_details.txt", "a")
puts "Enter your first name"
first_name=gets
puts "Enter your last name"
last_name=gets
puts "Enter your email address"
email=gets
customer_info=[]
customer_info[0]=first_name
customer_info[1]=last_name
customer_info[2]=email
fileObj.syswrite(customer_info)



The method syswrite writes the contents of the file.

file4 = File.new("C:\\Ruby\\Sample", "r+")
puts file4.sysread(20)
file4.syswrite("ABCDEF")
# write ABCDEF from the 21st character onward.