Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inet Demo Java source code
#1

import java.net.*;
import java.io.*;

class InetDemo2
{
byte buff[];
InetAddress idr;
String addrmsg;
InetDemo2() throws UnknownHostException
{
buff=new byte[4];
idr=InetAddress.getLocalHost();
buff=idr.getAddress();
addrmsg=idr.getHostName()+"/";
}
public String toString()
{
for(int i=0;i<buff.length;i++)
addrmsg+=(buff[i] & 255) + ".";
return "The Local Host Address is"+addrmsg;
}
public static void main(String args[])throws UnknownHostException
{
InetDemo2 d =new InetDemo2();
System.out.println(d);
}


}
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.