cabo / cbor-ruby

CBOR (RFC 7049) extension for Ruby
45 stars 12 forks source link

Encode binary file contents so can be decoded into Java byte array #6

Closed twigbranch closed 7 years ago

twigbranch commented 7 years ago

I'm trying to CBOR encode contents of a binary file so that it can be decoded by Java into a byte array. When I do 'open(path + filename) { |file| file.read }.to_cbor' I get a String after decoding in Java. When I do 'open(path + filename) { |file| file.read }.bytes.to_a.to_cbor' I get an ArrayList after decoding in Java. What's the correct way to use this library so the binary file contents are encoded as a byte array?

twigbranch commented 7 years ago

Using File.open with the 'b' attribute, or IO.binread works.