how to find shared drive IP address if i have a path for that shared drive in java or cmd prompt

StackOverflow https://stackoverflow.com/questions/12789033

  •  06-07-2021
  •  | 
  •  

Domanda

I have a path windows network shared drive like this .

String url="//sample/data/Documents/network/test/";

How can i find the Ip address of the that drive using this path using a java program or cmd prompt?

È stato utile?

Soluzione

Although @Greg is right I think in most cases you can extract the host name from the URL and then use InetAddress.getByName(), i.e. something like the following

String host = url.substring(2).replaceFirst("/.*", "");
InetAddress.getByName(host);

Altri suggerimenti

Via cmd prompt, you can get the IP pinging to 'sample' (following your example in the question) as the console must resolve hostname to IP address.

Via java, perhaps InetAddress.getByName('sample') could work.

All this assuming the shares are not going over NetBIOS and all the old stuff. That doesn't work over IP as the comment says.

Open windows cmd prompt, type in nslookup \network_share_drive_name it will come back with name and address of your gateway server and the network share drive. Here you can type nslookup \sample

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top