WebSphere MQ Messenger Java GUI  1.0
GNU Free Software License
 All Classes Namespaces Files Functions Variables
UtilsClass.java
Go to the documentation of this file.
1  /* Websphere MQ Client - Connects and sends or receives messages from WebSphere (IBM) Application Server
2  * WebSphere is Copyright IBM
3  Copyright (C) 2012 David Welford-Costelloe (http://www.welford-costelloe.org)
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 package com.ca.on.burlington.base.classes;
19 
20 import java.net.InetAddress;
21 import java.net.UnknownHostException;
22 
27 public class UtilsClass {
28 
29  private String ipAddress = null;
30  private String localMachineName = null;
31 
35  public String getIpAddress() {
36  return ipAddress;
37  }
38 
42  public String getLocalMachineName() {
43  return localMachineName;
44  }
45 
49  public UtilsClass() {
50  this.ipAddress = getComputerIP();
52 
53  }
54 
60  private String getComputerIP() {
61  String ipAddress = null;
62  try {
63  InetAddress inetAddress = InetAddress.getLocalHost();
64  ipAddress = inetAddress.getHostAddress();
65  } catch (UnknownHostException e) {
66  // TODO Auto-generated catch block
67  e.printStackTrace();
68  }
69  return ipAddress;
70  }
71 
77  private String getComputerName() {
78  String computername = null;
79  try {
80  computername = InetAddress.getLocalHost().getHostName();
81  } catch (UnknownHostException e) {
82  // TODO Auto-generated catch block
83  e.printStackTrace();
84  }
85  System.out.println(computername);
86  return computername;
87  }
88 
89 }

Check Out David's Web Site http://www.welford-costelloe.org

GNU Free Software: http://www.gnu.org/philosophy/free-sw.html