Results 1 to 3 of 3

Thread: ping cmd

  1. #1
    kishi is offline Member
    Join Date
    Nov 2007
    Posts
    2
    Rep Power
    0

    Default ping cmd

    Hi,

    how to run ping (dos command) command by writting a JAVA programm

    Thanks in advance

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    There may be an example in Suns' web site. Have you check there.

  3. #3
    henry_78 is offline Member
    Join Date
    Aug 2007
    Posts
    47
    Rep Power
    0

    Default

    U can do that by creating a new process and running there the dos command.

    //Creating a new process
    Process p = null;
    InputStreamReader isr = null;
    BufferedReader br = null;
    String line = null;

    Runtime rt = Runtime.getRuntime();
    try {
    p = rt.exec("cmd");
    p = rt.exec("ipconfig /all");
    }
    catch(IOException) {
    isr = new InputStreamReader(p.getInputStream());
    br = new BufferedReader(isr);
    try {
    line = br.readLine();
    while (line != null) {
    System.out.println(line);
    line = br.readLine();
    }
    }

Similar Threads

  1. Ping pong game
    By adam405 in forum New To Java
    Replies: 8
    Last Post: 10-20-2010, 03:52 PM
  2. How to mesure ping delay in JAVA..?
    By sacr83 in forum Networking
    Replies: 4
    Last Post: 06-15-2008, 06:37 AM
  3. Replies: 1
    Last Post: 02-15-2008, 04:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •