How do I know my router IP with the help of java?
import java.io.*;
import java.util.*;
public class ExecTest {
public static void main(String[] args) throws IOException {
Process result = Runtime.getRuntime().exec("traceroute -m 1 www.amazon.com");
BufferedReader output = new BufferedReader(new InputStreamReader(result.getInputStream()));
String thisLine = output.readLine();
StringTokenizer st = new StringTokenizer(thisLine);
st.nextToken();
String gateway = st.nextToken();
System.out.printf("The gateway is %s
", gateway);
}
}
Source: By Frank Krueger as answer to the question
This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 2.5
Related code-snippets:
- How do I use the C socket API in C++ on Linux?
- How do I convert a CSV into an XML file in Java?
- Is Object Property accessible from within object method?
- What is the meaning of the type safety warning in some Java generics casts?
- What is the difference between Int and Integer in Java and C#?
- How can I add custom button in Java?
- What are the different methods to parse strings in Java?
- How can I reverse DNS for Ruby?
- Is it illegal to throw a Null parameter without a NullPointerException for that parameter?
- What tools are good for code analysis?
- How do I read from a file that is actually being written to?
- Why is Java autoboxing used only for method invocations and not classes. The type has a class and an operator and the methods are autoboxed, doesn't this mean revocations of the method can be invoked?
- How can I use Java webstart multiple libraries?
- Is it better to use widening vs autoboxing?
- How can I access post variables using Java Servlets?