J
jf
Hi.
I am doing an application (MIDP) that parses XML from a TCP connection.
I then submit the XML to the SAX Parser and then i parse it normally
using the events. All this ok if the socket receives the exactly
chuncks of that with well formed XML. But sometimes (if the broadband
is small) my socket reader cath's for example n bytes:
<p><xpto>sadasd<xpt
then it processes submit to the parser (it won't work because is not
well formed) and then i receive from the socket:
o>adasdsad</p>
i want to know if i can force the inputstream to be larger. Of course i
can read it byte byte, but then i must code a pre-parser that will
build the xml to the sax parser (or i code my own parser...pff)
Actually my socket reader is a thread running and wainting for data on
a inputstream. The run method is like this:
public void run() {
while(keepLooping)
{
try
{
int bytesavail = is.available();
if(bytesavail>0)
{
byte b[] = new byte[bytesavail];
int count = is.read(b,0,bytesavail);
if(count !=0)
{
String sResponse = new String(b,0,count,"ISO-8859-1");
listener.Read(sResponse);
}
}
else
try
{
sleep(1000);
}
catch(Exception e)
{
System.out.println("sleep error");
}
}
catch(Exception e)
{
System.out.println("Erro");
}
}
thanks
joao
I am doing an application (MIDP) that parses XML from a TCP connection.
I then submit the XML to the SAX Parser and then i parse it normally
using the events. All this ok if the socket receives the exactly
chuncks of that with well formed XML. But sometimes (if the broadband
is small) my socket reader cath's for example n bytes:
<p><xpto>sadasd<xpt
then it processes submit to the parser (it won't work because is not
well formed) and then i receive from the socket:
o>adasdsad</p>
i want to know if i can force the inputstream to be larger. Of course i
can read it byte byte, but then i must code a pre-parser that will
build the xml to the sax parser (or i code my own parser...pff)
Actually my socket reader is a thread running and wainting for data on
a inputstream. The run method is like this:
public void run() {
while(keepLooping)
{
try
{
int bytesavail = is.available();
if(bytesavail>0)
{
byte b[] = new byte[bytesavail];
int count = is.read(b,0,bytesavail);
if(count !=0)
{
String sResponse = new String(b,0,count,"ISO-8859-1");
listener.Read(sResponse);
}
}
else
try
{
sleep(1000);
}
catch(Exception e)
{
System.out.println("sleep error");
}
}
catch(Exception e)
{
System.out.println("Erro");
}
}
thanks
joao