Reputation: 18124
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
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