JRuby and nio.ByteBuffer


#1

How to handle java.nio.ByteBuffer in JRuby?

buffer = ByteBuffer.allocate(1024)
buffer.array # gives us a java array but can we end up with a ruby
array?

“from_java” technique does not seem to be available.

Thanks
Paul F.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

buffer.array.to_a will give you an array with the contents of the
buffer, although it will construct a new array…which may not be what
you want?

-Tom

On Thu, Apr 9, 2009 at 9:44 AM, Paul F. removed_email_address@domain.invalid wrote:


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Blog: http://www.bloglines.com/blog/ThomasEEnebo
Email: removed_email_address@domain.invalid , removed_email_address@domain.invalid


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#3

You probably want String.from_java_bytes(buffer.array).

  • Charlie

Thomas E Enebo wrote:

buffer.array # gives us a java array but can we end up with a ruby array?


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email