last day (15 days later) » 

12:23
0
Q: ByteBuffer Missing Data When decoded As string

edwinI'm reading and writing to a ByteBuffer import org.assertj.core.api.Assertions; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset....

Without reading the question, Have you provided an encoding?
yes , Please see my code in question
Okay, I will compile the code my side and verify the issue if someone else hasn't already before me.
Where did you place your last code? Can you provide working example?
see updates , please remove Assertions before executing code
The output looks fine to me, The integer isn't missing.
12:23
so you mean the print statement contians 35 'System.out.println(dataString);' ??
I see 33 on both... this is first output messageDecoded=CARR0033TRANSACTION IGNORED+ and this is the second output #CARR0033TRANSACTION IGNORED+ only thing that changed is there is #
messageBuffer2.putInt(messageLength);
sorry about the confustion
Okay, It wasn't clear enough which because you just showed output of the data.
System.out.println(messageBuffer2.getInt()); doesn't this prints out the 35 so what's the issue here?
yes that's the issue
It shows 35 for me, but after that you can't get the data correct? you want to get the data after getting the int?
12:26
yes
Okay let me do some testing
we can summaries , whatever i write to buffer using put is retrieved in the string, putInt didn't retrieved in the string
What I am getting is that calling messageBuffer2.get(data);after calling getInt() causes BufferUnderflowException
Okay I fixed BufferUnderflowException but it only returns the #
Okay
I fixed it
I am posting an answer
@edwin can you try it and see if it's resolved?
 
2 hours later…
14:47
yes , the issue is fixed
can you please give be explanation, what is the logic behind use of clear fix the issue

last day (15 days later) »