Skip to content

Instantly share code, notes, and snippets.

@muraoka-edo
Created September 29, 2014 02:27
Show Gist options
  • Save muraoka-edo/9576caddd2158873c666 to your computer and use it in GitHub Desktop.
Save muraoka-edo/9576caddd2158873c666 to your computer and use it in GitHub Desktop.
[Ruby] File-sample
# Read(line by line)
File.open 'fname' do |f|
f.each_line do |line|
puts line
end
end
# Read(Slurp)
File.open 'fname' do |f|
puts f.read
end
# Write
File.open 'fname', w do |f|
f.write 'hogehoge'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment