Shows the values of the system properties : System Properties « J2ME « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » J2ME » System Properties 




Shows the values of the system properties
Shows the values of the system properties


/*
 * @(#)MIDletProps.java 1.0 00/07/18
 * Copyright (c) 1999,2000 Sun Microsystems, Inc. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of Sun
 * Microsystems, Inc. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Sun.
 *
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
 * THIS SOFTWARE OR ITS DERIVATIVES.
 */

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
 * A MIDlet shows the values of the system properties.
 */
public class MIDletProps extends MIDlet implements CommandListener
{

    private Display display;    // The display for this MIDlet
    private Form props;
    private StringBuffer propbuf;
    private Command exitCommand = new Command("Exit", Command.SCREEN, 1);


    /**
    * Construct MIDletProps
    */
    public MIDletProps() {
        display = Display.getDisplay(this);
    }

    /**
     * Show the value of the properties
     */
    public void startApp() {
       Runtime runtime = Runtime.getRuntime();
       runtime.gc();
       long free = runtime.freeMemory();
       long total = runtime.totalMemory();
    
       propbuf = new StringBuffer50 );
       props = new Form"System Properties" );
    
       props.append"Free Memory = " + free + "\n" );
       props.append"Total Memory = " + total + "\n" );
    
       props.appendshowProp"microedition.configuration" ) );
       props.appendshowProp"microedition.platform" ) );
       props.appendshowProp"microedition.locale" ) );
       props.appendshowProp"microedition.encoding" ) );
       props.appendshowProp"microedition.encodingClass" ) );
       props.appendshowProp"microedition.http_proxy" ) );
    
       props.addCommandexitCommand );
       props.setCommandListenerthis );
       
       display.setCurrentprops );

    }

    /**
    * Eventhandling code goes into commandAction
    */
    public void commandActionCommand c, Displayable s 
    {
      if c == exitCommand 
      {
         destroyAppfalse );
         notifyDestroyed();
      }  
    }


    /**
     * Show a property.
     */
   String showPropString prop 
   {
      String value = System.getPropertyprop );
      propbuf.setLength);
      propbuf.appendprop );
      propbuf.append" = " );
      if (value == null
      {
         propbuf.append"<undefined>" );
      
      else 
      {
          propbuf.append"\"" );
          propbuf.appendvalue );
          propbuf.append"\"" );
      }
      propbuf.append"\n" );
      return propbuf.toString();
    }


   /**
    * Time to pause, free any space we don't need right now.
    */
    public void pauseApp() 
    {
       display.setCurrentnull );
       propbuf = null;
       props = null;
    }

    /**
     * No op
     */
    public void destroyAppboolean unconditional 
    {
       System.out.println"In destroyApp" );

    }

}


           
       














Related examples in the same category
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.