Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8419351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:35:06+00:00 2026-06-10T02:35:06+00:00

I know that this question has been approached under different ways, but I have

  • 0

I know that this question has been approached under different ways, but I have checked stackoverflow and I didn’t found the answer I was looking for.

To make it simple : Is there a way to get the Time ping value to an IP server under Windows ?

I know how to check if some servers are reachable, but I would like to have precise values, like we can read on terminal.

Thank you for your help and understanding.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:35:07+00:00Added an answer on June 10, 2026 at 2:35 am

    You can do something like this :

    //The command to execute
    String pingCmd = "ping " + ip + " -t";
    
    //get the runtime to execute the command
    Runtime runtime = Runtime.getRuntime();
    Process process = runtime.exec(pingCmd);     
    
    //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 = in.readLine();
    }
    

    reference

    UPDATE: As per your need

    public class PingDemo {    
        public static void main(String[] args) {
            String ip = "localhost";
            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(pingCmd);
    
                //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("time")) {
                         time = inputLine.substring(inputLine.indexOf("time"));
                         break;                        
                    }
                    inputLine = in.readLine();
                }    
                System.out.println("time --> " + time);    
            } catch (Exception ex) {
                System.out.println(ex);
            }
        }
    }
    

    Written in little haste.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that this sort of question has been asked here before, but still
I know that this question has been asked several times and I've read all
I know that this question must have been asked and answered a million times,
I know this question has been asked quite a few times, however, I have
I know this question has been asked already but I would like to solve
I know this question has been asked before, but none of the existing SO
I know this question has been asked before but I'm confused as to the
I know this question has been asked million times, but I'm not able to
I know that this topic has been beaten to death, but it seems that
I know this question has been asked multiple number of times and i have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.