To be or not to be.That is a question!

---源于莎士比亚的《哈姆雷特》

导航

ruby使用IO类读写文件

path="test.txt"
port=open(path)
begin
    port.each_line{|line|
        p line.to_s
    }
ensure
    port.close
end

STDOUT << "i love you \n"
port=open('test.txt')
s=port.stat
p s.ftype
p s.dev
p s.ino
p s.mode

p s.nlink

begin
    a=port.readlines
    a=port.each{|e| p e}
    ensure
        port.close
    end

 

                      

posted on 2013-07-03 16:16  Ijavascript  阅读(410)  评论(0编辑  收藏  举报