Created
September 29, 2014 02:27
-
-
Save muraoka-edo/9576caddd2158873c666 to your computer and use it in GitHub Desktop.
[Ruby] File-sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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