/* * This file was derived from libdissipate, an open source SIP library. The original file * was modified on 1/23/2001. Please see * http://www.div8.net/dissipate for more information. * * Copyright (c) 2000 Billy Biggs * * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Library General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public * License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * */ /** * class SipUtil * * Container class for useful functions needed by the stack in general. I'd * like to put these somewhere else. They're not needed outside of the stack. * * This code has been generated using C2J++ * C2J++ is based on Chris Laffra's C2J (laffra@watson.ibm.com) * Read general disclaimer distributed with C2J++ before using this code * For information about C2J++, send mail to Ilya_Tilevich@ibi.com */ package org.mitre.jsip; import java.io.File; import java.net.InetAddress; import java.net.UnknownHostException; public class SipUtil { /** * SipUtil */ public SipUtil() {} /** * getLocalFqdn * @return char* */ public static String getLocalFqdn() { if ( dissipate_our_fqdn == null ) { findFqdn(); } return dissipate_our_fqdn; } /** * checkFilename * @param filename * @return bool */ public boolean checkFilename(String filename) { File fd = new File(filename); return fd.exists(); } /** */ static void findFqdn() { InetAddress hostAddr = null; try { hostAddr = InetAddress.getLocalHost(); } catch (UnknownHostException uhe) { System.err.println("Couldn't get InetAddress for localhost"); dissipate_our_fqdn = "Unknown"; return; } dissipate_our_fqdn = hostAddr.getHostName(); } // class variables static String dissipate_our_fqdn = null ; /** * test method */ public static void main( String[] args ) { System.out.println("The local hostname found is " + SipUtil.getLocalFqdn()); } }