-
-
Save blinsay/1a7c9f30e9fd18a4a1bf to your computer and use it in GitHub Desktop.
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
[6] pry(main)> def write_bytes_to_stream(thing) | |
[6] pry(main)* bs = ByteArrayOutputStream.new(1024) | |
[6] pry(main)* bs.write(thing) | |
[6] pry(main)* bs.flush | |
[6] pry(main)* bs.close | |
[6] pry(main)* bs.to_byte_array | |
[6] pry(main)* end | |
=> nil | |
[8] pry(main)> write_bytes_to_stream("hi there".to_java_bytes) | |
=> byte[104, 105, 32, 116, 104, 101, 114, 101]@53251a66 | |
[9] pry(main)> write_bytes_to_stream(1023) | |
=> byte[-1]@20f5281c | |
[10] pry(main)> write_bytes_to_stream(1024) | |
=> byte[0]@38604b81 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment