is there is a way to know my DNS in java?
hello there
i wonder if there is a way to know my DNS and therefore the internet host company?
hello there
i wonder if there is a way to know my DNS and therefore the internet host company?
> hello there
> i wonder if there is a way to know my DNS and
> therefore the internet host company?
Not that I know of. You can still get the ISP in a round about ugly, brittle fashion. On Windows XP you can do this:
import java.io.IOException;
import java.io.InputStream;
public class PSOutput {
public static void main(String[] args) {
try {
String command = "cmd /c ipconfig";
Process child = Runtime.getRuntime().exec(command);
InputStream in = child.getInputStream();
int c;
StringBuilder sb = new StringBuilder();
while ((c = in.read()) != -1) {
sb.append((char)c);
}
in.close();
printISP(sb.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
static void printISP(String output){
String startPattern = ". : ";
String endPattern = "\r\r\n";
int beginIdx = output.indexOf(startPattern)+ startPattern.length();
int endIdx = output.indexOf(endPattern, beginIdx);
System.out.println(output.substring(beginIdx,endIdx));
}
}
As you can see it is ugly and is not really a reliable process, not sure that there is another way though.
Which operating system you using? Also which IDE? if it Eclipse then it could be that the console didn't pop up but the output is there.
Works fine for on XP
EDIT:
Also try typing "ipconfig" on command promt and make sure there is some data after "Connection-specific DNS Suffix . : isp should be here"
Message was edited by:
_helloWorld_
> hello there
> i wonder if there is a way to know my DNS and
> therefore the internet host company?
Huh?
How exactly does getting your nameservers help you with this?
What information are you actually looking for? What are you trying to figure out?
> Also try typing "ipconfig" on command promt and make
> sure there is some data after "Connection-specific
> DNS Suffix . : isp should be here"
Often not.
> ...
> Also try typing "ipconfig" on command promt and make
> sure there is some data after "Connection-specific
> DNS Suffix . : isp should be here"
>
> Message was edited by:
> _helloWorld_
There could be nothing after the Connection-specific DNS Suffix.
> > Also try typing "ipconfig" on command promt and
> make
> > sure there is some data after "Connection-specific
> > DNS Suffix . : isp should be here"
>
> Often not.
Thats probably the trouble he is having, I have my ISP listed there and thought it to be standard but it doesn't look like it.
If you want the domain name of the name servers then get the dns ip addreses and then use InetAddress to get the hostname.
Again though this request seems very mysterious to me.
> i'm using win xp-JCreator IDE
> i want to know my ISP name and any useful information
> about my ISP
Yes well.
This is not a Java suitable project.
It's not even a software suitable project to be honest.
So I recommend giving it up.
If you do decide to continue then you need to start by telling us what "all useful information" about your ISP means.
I will not write any Java code. Go to this URL and check if this is
what you need: http://www.checkipinfo.com/
If yes, you need to write the code that opens this URL and parses
the page. Even better, maybe you can find a web service that does
this, in which case you avoid the parsing.