view examples/util/DumpProperties.java @ 0:bf79fb79ee13

Initial Mercurial check in.
author samer
date Tue, 17 Jan 2012 17:50:20 +0000
parents
children
line wrap: on
line source
package eg.util;

import java.util.Properties;
import java.util.Enumeration;

import java.net.InetAddress;

public class DumpProperties
	{
	public static void main(String[] args)
		{
		Properties props = System.getProperties();
		Enumeration enum = props.propertyNames();

		System.out.println("System Properties");
		while( enum.hasMoreElements() )
			{
			String key   = (String)enum.nextElement();
			String value = props.getProperty(key);
			System.out.println(key + "\t" + value);
			}

		try 
			{
			InetAddress host = InetAddress.getLocalHost();
			String name = host.getHostName();
			String addr = host.getHostAddress();

			System.out.println("hostname = " + name);
			System.out.println("address  = " + addr);
			}
		catch ( Exception e )
			{
			System.err.println("Exception looking up local host name");
			e.printStackTrace();
			}
		}
	}