Line break while reading bulk String using DataInputStream's read()

Hi All,

I am writing a TCP socket client which connects to the server and issues a command ( i.e., writes onto the socket using DataOutputStream's write() ) and in return gets back few pages of output which i will be reading using DataInputStream's read(). The problem is after reading few lines randomly one of the line breaks into two because of which the regular expression cannot match this line.

Hence , i would like to know if there is any know issue w.r.t reading bulk string which consists of few hundreds of lines.

The following is the code :

private DataInputStream dis = null;

private DataOutputStream dos = null;

dos.write(new String(mmlCommand).getBytes());

byte[] byteArray = new byte[8192];

while((dis.read(byteArray)) != -1 ) {

Result = new String(byteArray);

...

...

}

When i print the Result i see that 20th line which the server is sending is breaks into 2 lines.

I am struck !! Looking forward for help !

regards

Chandra

[1045 byte] By [chanusa] at [2007-11-26 18:42:26]
# 1

I I understand correctly, you are trying to use a regular expression to examine the combined contents of several separate strings? This can't be done directly, the separate strings need to be combined to examine them all with one regular expression.

If this is not the problem, maybe a reading of the "Line terminators" paragraphs of the Pattern class API will reveal a solution.

ChuckBinga at 2007-7-9 6:16:27 > top of Java-index,Core,Core APIs...