systemproperties.java

来自「程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件」· Java 代码 · 共 33 行

JAVA
33
字号
package examples.collections;
import java.util.*;

/** A class to help demonstrate how to work with
  * system properties
  */
public class SystemProperties {
   /** Display the system properties specified as
     * input parameters or, if no input is given,
     * all the system properties
     * @param args the list of system properties
     *             to be displayed
     */
   public static void main( String[] args ) {
      if ( args.length > 0 ) {
         // dump selected system properties
         for ( int i=0; i<args.length; i++ ) {
            System.out.println( args[i] + ": " +
               System.getProperty( args[i],
                                   "not found" ) );
         }
      } else {
         // dump all system properties
         Properties sysProps = System.getProperties();
         Enumeration e = sysProps.propertyNames();
         while ( e.hasMoreElements() ) {
            String propName = (String)e.nextElement();
            System.out.println( propName + ": " +
               sysProps.getProperty( propName ) );
         }
      }
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?