Re: ByteBuffer to String

1,068 views
Skip to first unread message

Andy King

unread,
Jan 4, 2013, 1:44:43 PM1/4/13
to google-we...@googlegroups.com
I don't think ByteBuffer is available in GWT ... can you use the first solution suggested here: http://stackoverflow.com/questions/88838/how-to-convert-strings-to-and-from-utf8-byte-arrays-in-java

On Thursday, January 3, 2013 8:17:11 AM UTC-7, Andres Q wrote:

Hi!

I have the following Java code

import com.google.common.base.Charsets;
import java.nio.ByteBuffer;

ByteBuffer msg = ... // a ByteBuffer that contains a String
String s = Charsets.UTF_8.decode(msg).toString();

this works fine in Java, but when I try to compile it with GWT I get:

The method decode(ByteBuffer) is undefined for the type Charset

What's the proper way, in GWT, to obtain a String (encoded in UTF-8) that's inside a ByteBuffer?

Thanks!

ps: this question has also been asked in StackOverflow, if anyone wants to answer there and gain some rep

Benjamin Possolo

unread,
Jan 7, 2013, 4:03:54 PM1/7/13
to google-we...@googlegroups.com
ByteBuffer is not supported in GWT client code as documented here
so you should re-evaluate whatever you are doing with those first.

I dont know if that google library you are using for the charsets class works gwt client code either.
i would guess not.
Reply all
Reply to author
Forward
0 new messages