DarVar
DarVar

Reputation: 18124

int support in ChannelBuffer

Writing a DownstreamHandler and I need to encode an int to a ChannelBuffer.

ChannelBuffers.copiedBuffer(...) has a method which converts a string into a buffer.

How do I convert an int to a ChannelBuffer?

Upvotes: 0

Views: 100

Answers (1)

DarVar
DarVar

Reputation: 18124

Got a solution to this myself:

final ChannelBuffer myIntBuffer = channel.getConfig().getBufferFactory().getBuffer(4);

myIntBuffer.writeInt(myInt);

Hopefully it is the best/correct approach.

Upvotes: 1

Related Questions