File.open("/usr/local/widgets/data").each do |line|
puts line if line =~ /blue/
end
logfile = File.new("/tmp/log", "w")
logfile.close
File.expand_path('~/tmp')
fh = Tempfile.new('tmp')
fh.sync = true # autoflushes
10.times { |i| fh.puts i }
fh.rewind
puts 'Tmp file has: ', fh.readlines
Created
October 16, 2013 15:10
-
-
Save ascendbruce/7009252 to your computer and use it in GitHub Desktop.
Ruby File open read/write examples
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment