java ByteArrayOutputStream alternative in ruby.

G

Googy

Hi,

I am porting a library from java to ruby. My problem is simulating
ByteArrayOutputStream in ruby. I want to pack bytes integers and all
other kinds of data in to a stream buffer then get it as a packed
string and send it over network.

Thanks.
 
J

James Edward Gray II

I am porting a library from java to ruby. My problem is simulating
ByteArrayOutputStream in ruby. I want to pack bytes integers and all
other kinds of data in to a stream buffer then get it as a packed
string and send it over network.

Look-up Array#pack in your favorite documentation source.

James Edward Gray II
 
G

Googy

Look-up Array#pack in your favorite documentation source.

James Edward Gray II

Yeah, Did that before.
But My problem is I collect binary data as the program runs and then
send it over the network. So I want to know if there are any classes
proving in memory streams.

I have one more doubt, how do you concatenate two packed values, for
e.g you pack some stuff into a string at one location, and in some
other location you pack another chunk of binary data. And how do you
concatenate those two packed values, is normal string concatenation is
sufficient for concatenating two chunks of binary data packed in
strings ?
 
J

James Edward Gray II

Yeah, Did that before.
But My problem is I collect binary data as the program runs and then
send it over the network. So I want to know if there are any classes
proving in memory streams.

Well, String and Array can both be added too as needed, so I'm not
sure how they fail to meet your needs.
I have one more doubt, how do you concatenate two packed values, for
e.g you pack some stuff into a string at one location, and in some
other location you pack another chunk of binary data. And how do you
concatenate those two packed values, is normal string concatenation is
sufficient for concatenating two chunks of binary data packed in
strings ?

Sure.

James Edward Gray II
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top