convertion string to InetAddress

convertion string to InetAddress - Java - Programmation

Marsh Posté le 20-05-2008 à 22:17:04    

J’ai réalisé une application client-serveur_UDP, l’utilisateur fait entré l’adresse IP dans un JTextField....
Je veut convertir l’adresse IP qui était dans le  JTextField (elle est de type String) en InetAddress  
 :ouch:  Aide SVP  :ouch:

Reply

Marsh Posté le 20-05-2008 à 22:17:04   

Reply

Marsh Posté le 21-05-2008 à 08:31:09    

Citation :

getByName
 
public static InetAddress getByName(String host)
                             throws UnknownHostException
 
    Determines the IP address of a host, given the host's name.
 
    The host name can either be a machine name, such as "java.sun.com", or a textual representation of its IP address. If a literal IP address is supplied, only the validity of the address format is checked.
 
    For host specified in literal IPv6 address, either the form defined in RFC 2732 or the literal IPv6 address format defined in RFC 2373 is accepted.
 
    If the host is null then an InetAddress representing an address of the loopback interface is returned. See RFC 3330 section 2 and RFC 2373 section 2.5.3.
 
    Parameters:
        host - the specified host, or null.  
    Returns:
        an IP address for the given host name.  
    Throws:
        UnknownHostException - if no IP address for the host could be found.  
        SecurityException - if a security manager exists and its checkConnect method doesn't allow the operation
 


---------------

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed