Created
June 22, 2012 18:34
-
-
Save ajokela/2974420 to your computer and use it in GitHub Desktop.
Reading a file in one line - ruby
This file contains hidden or 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
# If you need binary mode, you'll need to do it the hard way: | |
s = File.open(filename, 'rb') { |f| f.read } | |
# If not, shorter and sweeter is: | |
s = IO.read(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment