Avatar of Zolf
Zolf
Flag for United Arab Emirates asked on

Java - Printing buffer data together

Hello there,

I have this piece of code and want to print out the data in the buffer,cam somebody please guide me how can i achieve it.

cheers
Zolf

 Buffer buf = Buffer.buffer();
            buf.appendByte((byte) 0x02).appendString("CLR").appendByte((byte) 0x03)
                    .appendByte((byte) 0x1b).appendString("K1").appendByte((byte) 0x0d)
                    .appendByte((byte) 0x1b).appendString("C").appendByte((byte) 0x0d)
                    .appendByte((byte) 0x1b).appendString("K2").appendByte((byte) 0x0d)
                    .appendByte((byte) 0x1b).appendString("C").appendByte((byte) 0x0d)
                    .appendByte((byte) 0x1b).appendString("K3").appendByte((byte) 0x0d)
                    .appendByte((byte) 0x1b).appendString("C").appendByte((byte) 0x0d)
                    .appendByte((byte) 0x1b).appendString("K4").appendByte((byte) 0x0d)
                    .appendByte((byte) 0x1b).appendString("C").appendByte((byte) 0x0d);
                    socket.write(buf);

Open in new window

JavaJava EE

Avatar of undefined
Last Comment
Zolf

8/22/2022 - Mon
dpearson

I don't think Buffer here is the standard Java buffer class - i.e. java.nio.Buffer

I suspect this is an internal class - in which case you'd need to look inside that class to see how it is representing the data and how to print it out.

If it contains a ByteBuffer then that has a getChar() method which you can use to read and print the current contents of the buffer.

Doug
Zolf

ASKER
thanks for your comments.

Yes I am using a 3rd party buffer class and the link to it is http://vertx.io/docs/apidocs/io/vertx/core/buffer/Buffer.html
ASKER CERTIFIED SOLUTION
dpearson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Zolf

ASKER
cheers
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23