Guest User

Untitled

a guest
May 20th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. package ping;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.InputStreamReader;
  5. import java.io.IOException;
  6. import javax.swing.*;
  7.  
  8. import java.io.BufferedReader;
  9. import java.io.InputStreamReader;
  10.  
  11. public class ping2 {
  12.  
  13. public static void runSystemCommand(String command) {
  14.  
  15. try {
  16. Process p = Runtime.getRuntime().exec(command);
  17. BufferedReader inputStream = new BufferedReader(new InputStreamReader(p.getInputStream()));
  18.  
  19. String s = "";
  20. // reading output stream of the command
  21. while ((s = inputStream.readLine()) != null) {
  22. System.out.println(s);
  23. }
  24.  
  25. } catch (Exception e) {
  26. e.printStackTrace();
  27. }
  28. }
  29.  
  30. public static void main(String[] args) {
  31.  
  32. String ip = "192.168.40.215";
  33. runSystemCommand("ping " + ip);
  34. }
  35. }
Add Comment
Please, Sign In to add comment