Reading sensor data from Arduino using Java Applicaton

Hi

I am reading sensor data from arduino from a Java application. The data is showing perfectly every 1 second on the serial monitor as below.

[23.75, 24.00, 24.00, 24.50, 23.50, 24.50, 24.50, 24.00,
24.00, 24.75, 24.25, 24.25, 23.75, 23.75, 23.50, 24.00,
23.00, 24.25, 24.25, 24.25, 23.75, 23.50, 23.75, 24.00,
23.75, 24.25, 24.50, 24.25, 23.50, 23.75, 23.25, 24.25,
23.50, 24.25, 23.75, 23.75, 23.75, 23.50, 23.25, 24.00,
23.25, 23.75, 24.00, 23.50, 23.75, 24.00, 24.00, 24.50,
23.25, 23.75, 24.25, 23.75, 23.50, 23.25, 24.00, 24.25,
23.50, 24.00, 24.00, 24.00, 24.00, 23.75, 24.00, 24.75,
]

But when I read the data from my Java application it shows like below.

4.25
,24
.50,
24.
00,
24.0
0,2
3.7
5,2
4.00
,24
.00,
2
3.50
,24
.25,
24.
00,
24.5
0,2
3.75
,23.75,
23.50,
24.
00,
24.00,
24.
00,24.25,2
3.75
,23.25,
23.
50,23.5
0,24.00,
23.75,23.5
0,24.00
,24.25,
23.25,
24.00,2
23.5
0,23.25
,23
.75,
24.
00,23.7
5,2
3.00
,23
.50,
24.
23
.50,23
.75,
24.25,
24.0
0,2
4.00,23
.75,24.
00,
24.75,
]

There are /n escape characters in the string. I am using import jssc.SerialPort; library for serial port communication. The code used to connect to serial port is:
serialPort.setParams(9600, 8, 1, 0)

I am using an event listener to read the data as below

byte[] buf = this.serialPort.readBytes();
if (buf == null || buf.length <= 0) {
return;

}
String op = new String(buf, 0, buf.length);
op=op.replaceAll("[\n\t ]", "");

Also I tried to replace the escape characters to no avail. Can somebody give me any ideas as to what could be wrong?

Thanks in advance!

As you need help with a Java program you should ask on a Forum that deals with Java.

Arduinos are programmed in C++

...R

You make the assumption that you will receive all data in one go. That is incorrect; serial communication is slow.

So you will receive e.g. two characters, next 3 characters, next 1 character and so on.

I'm not a java programmer but do suggest that you post your full code for both the Arduino and Java.