Hi,
I am reading data from socket channle by connecting to remote server from my machine.
I am reading all the data but the data is going to be duplicate in some cases.
buffer.clear() is not clearing all the data.
Suppose if I read first 100 bytes. Whne reading next 100 bytes and if there any spaces then
the spaces are going to replace with previous data. Why is it happening.
How do I read data with duplicate even if there any spaces in the data.
Here is the code i am trying to use to read data.
try {
requestByteBuffer = ByteBuffer.wrap(request, 0, request.length);
channel.write(requestByteBuffer);
buffer = ByteBuffer.allocate(100);
sbResponse = new StringBuffer();
loop: while (channel.read(buffer) > 0) {
array = new byte[100];
buffer.position(0);
buffer.get(array, 0, 100);
str = new String(array);
sbResponse.append(str);
buffer.clear();
}
}catch(Exception e) { }
Thanks,
Madhavi.