Search code examples
javapathcmdwindows-share

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


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?


Solution

  • 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);