Bonjour... J'ai cette classe qui fait le Ping d'un ip ou site... et affiche le temps de paquets ..

mais la probléme quelle affiche juste le temps de premier paquet je veux quelle affiche le temps de tout les paquet
quelque soit ''n'' ==> ping -n

Comment corriger ça ?


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
public class Ping {    
    public static void main(String[] args) {
        String ip = "developpez.net";
        String time = "";
 
        //The command to execute
        String pingCmd = "ping " + ip;
 
        //get the runtime to execute the command
        Runtime runtime = Runtime.getRuntime();
        try {
            Process process = runtime.exec("ping -n 6 " + ip);
 
            //Gets the inputstream to read the output of the command
            BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
 
            //reads the outputs
            String inputLine = in.readLine();
            while ((inputLine != null)) {
                if (inputLine.length() > 0 && inputLine.contains("temps")) {
                     time = inputLine.substring(inputLine.indexOf("temps"));
                     break;    
 
                }
 
                inputLine = in.readLine();
 
            }  
 
            System.out.println("time --> " + time);    
 
        } catch (Exception ex) {
            System.out.println(ex);
        }
    }
}