[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: How to update a file?

7stud --

5/11/2008 12:29:00 AM

Cheyne Li wrote:
> Hi there
>
> Does anyone know how to write a string at the end of a file?

contents = IO.read("data.txt")
print contents
puts

File.open("data.txt", "a") do |file|
file.print("this is the last line\n")
end

new_contents = IO.read("data.txt")
print new_contents


--output:--
hello
world
goodbye

hello
world
goodbye
this is the last line
--
Posted via http://www.ruby-....