I am wondering is it possible to put a delay on how often a packet is read by the buffered reader when being read from a socket. At the moment there is a server which streams data over local host to a client which reads in the data and splits it. I would like the data not to be read continuously and rather would like to read in a packet every 1/2 second. Below is the code I currently have:
Set up of the BufferedReader:
`
Socket clientSocket = new Socket("localhost", 1240);
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
'
This section of code is where the packets are read in:
while (true)
{
String line = inFromServer.readLine();
if (line != null){
String[] packetData = line.split(",");
if (packetData.length == 5)
{
x = Double.parseDouble(packetData[1]);
y = Double.parseDouble(packetData[2]);
z = Double.parseDouble(packetData[3]);
}
}
}
If anyone could give me help on this it would be greatly appreciated. Thanks. Daniel