| | |

Finding the localhost IP

// package sampleprograms;
import java.io.*;
import java.net.*;

/**
*
* @author katta vijay
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

try{
String ip =  InetAddress.getLocalHost().getHostAddress();
System.out.println(ip);
}catch(Exception e){
}
}

}
—————————————————-output is————————
10.0.0.223

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *