Strumenti Utente

Strumenti Sito


lpr-b:lpr-b-09:soluzioni

Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

Entrambe le parti precedenti la revisioneRevisione precedente
Prossima revisione
Revisione precedente
lpr-b:lpr-b-09:soluzioni [22/10/2009 alle 20:32 (16 anni fa)] Andrea Corradinilpr-b:lpr-b-09:soluzioni [22/10/2009 alle 20:42 (16 anni fa)] (versione attuale) Andrea Corradini
Linea 4: Linea 4:
  
 [[FAQ|FAQ]] [[FAQ|FAQ]]
 +
 +
 +====== Tasks e Threads ======
  
 ===== PrintTask ===== ===== PrintTask =====
Linea 99: Linea 102:
 </code> </code>
  
-====== Tasks e Threads ====== 
 ===== PITask2 ===== ===== PITask2 =====
  
Linea 374: Linea 376:
 </code> </code>
  
 +====== Indirizzi IP ======
 +
 +===== ListInterface =====
 +<code:java>
 +import java.util.Enumeration;
 +import java.net.*;
 +
 +public class ListInterface
 +{
 +    public static void main(String[] args)
 +    {
 + try
 +     {
 + Enumeration<NetworkInterface> interfaceList = NetworkInterface.getNetworkInterfaces();
 + if(interfaceList == null)
 +     {
 + System.out.println("Nessuna interfaccia di rete disponibile");
 +     }
 + else
 +     {
 + while(interfaceList.hasMoreElements())
 +     {
 + NetworkInterface iface = interfaceList.nextElement();
 + System.out.println("Interface " + iface.getName() + ":->" + iface.getDisplayName());
 + Enumeration<InetAddress> addrList = iface.getInetAddresses();
 + while(addrList.hasMoreElements())
 +     {
 + InetAddress address = addrList.nextElement();
 + System.out.print("\tIndirizzo " + ((address instanceof Inet4Address ? "(v4)"
 +     : (address instanceof Inet6Address ? "(v6)" : "(?)"))));
 + System.out.println(": " + address.getHostAddress());
 +     }
 +     }
 +     }
 +     }catch(SocketException e) { System.out.println(e);}
 +    }
 +}
 +</code>
lpr-b/lpr-b-09/soluzioni.1256243536.txt.gz · Ultima modifica: 22/10/2009 alle 20:32 (16 anni fa) da Andrea Corradini

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki