I have a string that is in a while loop to be sent from client to server multiple times but I want it to be sent only one time per a minute. How can I do it, any ideas !!?
Here is the code:
String str= " ";
try{
FileInputStream fstream = new FileInputStream("C:\\bluetooth.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
while ((str = br.readLine()) != null) {
if ( str.equals.("F81EDF5B0CC7")) // "F81EDF5B0CC7" is a String that I have it in the text file 'bluetooth.txt'
{
out.writeUTF(str);
}
}
in.close();
}catch (Exception e){
System.err.println("Error: " + e.getMessage());
}
Please help and thanks in advance.
Use
Timer.scheduleAtFixedRate(..)Taken from here.