Help me for the following
I am using jdk1.5.0_18 and I have code to read data from a weighing machine .
I can read the data successfully . But there is problem while reading data the output which I am getting is repeatedly running .Is there any way to stop while getting the output and again read while the data is changed?
My codes:
case SerialPortEvent.DATA_AVAILABLE:
{
System.out.println("data available...");
String weight_Array[]=new String[8];
int c,i=0;
try{
while((ins.available())>0)
{
if((ins.available())==0)
break;
else
{
c=(char)ins.read();
char ch=(char)c;
weight_Array[i]=Character.toString(ch);
i++;
}
}
System.out.println("out of while");
for(int j=0;j<=8;j++)
{
System.out.print(weight_Array[j]+"$");
}
calc_weight(weight_Array);
}catch(IOException e)
{
System.out.println(e);
}
break;
}
}
}
});
}catch(Exception e)
{
System.out.println(e);
}