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?

[108 byte] By [microsmarta] at [2007-11-27 11:20:15]
# 1

> 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.

_helloWorld_a at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 2

your code compiles fine but it didn't run!

microsmarta at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 3

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_

_helloWorld_a at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 4

> 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?

cotton.ma at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 5

> 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.

cotton.ma at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 6

> ...

> 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.

prometheuzza at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 7

> > 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.

_helloWorld_a at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 8

[Edit: nevermind, I thought it was a reply from the OP]

prometheuzza at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 9

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.

cotton.ma at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 10

i'm using win xp-JCreator IDE

i want to know my ISP name and any useful information about my ISP

microsmarta at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 11

> 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.

cotton.ma at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 12

If you do decide to continue then you need to start by telling us what "all useful information" about your ISP means.

cotton.ma at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 13

i want to know my DNS server address

and my ISP name

is that possible

microsmarta at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 14

> and my ISP name

> is that possible

What do you mean by ISP name? Why again do you want to know?

cotton.ma at 2007-7-29 14:41:29 > top of Java-index,Java Essentials,New To Java...
# 15

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.

baftosa at 2007-7-29 14:41:34 > top of Java-index,Java Essentials,New To Java...