NetworkInterface toString Example

NetworkInterface class toString example. This example shows you how to use toString method.


NetworkInterface class toString example. public String toString() Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object.

Here is the code
/*
 * @ # ToString.java
 * A class repersenting use to toString method 
 * of URL class in java.net package
 * version 23 June 2008
 * author Rose India 
 */

import java.net.*;

public class ToString {

    public static void main(String args[]) throws Exception {

        byte b[] {127001};
        InetAddress inetAddress = InetAddress.getByAddress(b);
        NetworkInterface networkInterface =
                NetworkInterface.getByInetAddress(inetAddress);
        System.out.println(networkInterface.toString());
    }
}

Output
name:lo (lo) index: 1 addresses:
/0:0:0:0:0:0:0:1%1;
/127.0.0.1;

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US