strange Java problem

Status
You're currently viewing only newton_meter's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

newton_meter

Ars Scholae Palatinae
1,424
Originally posted by Sir Arthur:
i get it from the originally send packet (coming from the client)

rcvString = packet.getData();

but what difference would the way how get the string make, i wonder?

Err, how big is your DatagramPacket? N bytes? Then rcvString contains N characters? Then appending stuff to rcvString puts that stuff after the first N characters? Then trying to cram N+X characters into a DatagramPacket that can only hold N characters causes the last X characters to be truncated? D'oh.

And if you build the StringBuffer backwards, you get a string buffer with X+N characters; and when you try to cram that into a DatagramPacket that can only hold N characters, you get all of the first X characters and some of the last N? That's consistent with what I would expect to happen whenever X < N.

(kg*m*m)/(s*s)
 
Status
You're currently viewing only newton_meter's posts. Click here to go back to viewing the entire thread.
Not open for further replies.