JRuby and nio.ByteBuffer

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

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. [email protected] wrote:


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Blog: http://www.bloglines.com/blog/ThomasEEnebo
Email: [email protected] , [email protected]


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs