KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > util > NetworkKit


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package org.jgap.util;
11
12 import java.net.*;
13
14 /**
15  * Houses network-related functionality.
16  *
17  * @author Klaus Meffert
18  * @since 2.4
19  */

20 public final class NetworkKit {
21
22   /** String containing the CVS revision. Read out via reflection!*/
23   private final static String JavaDoc CVS_REVISION = "$Revision: 1.2 $";
24
25   /**
26    * Private constructor because it's utility class
27    */

28   private NetworkKit() {
29
30   }
31
32   /**
33    * @return IP address string in textual presentation
34    * @throws UnknownHostException
35    *
36    * @author Klaus Meffert
37    * @since 2.4
38    */

39   public static String JavaDoc getLocalIPAddress()
40       throws UnknownHostException {
41     return InetAddress.getLocalHost().getHostAddress();
42   }
43
44   /**
45    * @return name of the computer calling this function locally
46    * @throws UnknownHostException
47    *
48    * @author Klaus Meffert
49    * @since 2.4
50    */

51   public static String JavaDoc getLocalHostName()
52       throws UnknownHostException {
53     return InetAddress.getLocalHost().getHostName();
54   }
55
56 }
57
Popular Tags