Hi,
If coded as follows:-
str = String.from_java_bytes(byte_array_output_stream.to_byte_array)
Presumably, the output stream is copied to a java byte array, and the
byte array is either cast or copied to the ruby string.
Is this the only, or best way to do this?
Regards
Paul F Fraser
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
On Thu, Dec 10, 2009 at 11:07 PM, Paul F Fraser [email protected]
wrote:
Hi,
If coded as follows:-
str = String.from_java_bytes(byte_array_output_stream.to_byte_array)
Presumably, the output stream is copied to a java byte array, and the byte
array is either cast or copied to the ruby string.
Is this the only, or best way to do this?
If you’re starting with a byte array output stream, then I’d say that
yes, this is probably the most compact way of doing it. The only other
thing would be if you wanted to make it shorter, you could define a
method like this:
class java::io::ByteArrayOutputStream
def to_str
String.from_java_bytes(to_byte_array)
end
end
Then you could simply do byte_array_output_stream.to_str.
Cheers,
/Nick
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email