• 项目总结69: System.getenv()和System.getProperties()


    项目总结69: System.getenv()和System.getProperties()

    START

    import java.util.Map;
    import java.util.Properties;
    import java.util.Set;
    
    public class SystemEnvironmentTest {
    
        public static void main(String[] args) {
            //Java提供了System类的静态方法getenv()和getProperty()用于返回系统相关的变量与属性
    
            // getenv方法返回的变量大多于系统相关
            Map<String, String> envMap = System.getenv();
            Set<String> keySet = envMap.keySet();
            for(String key : keySet){
                System.out.println("key = " + key + "  ||   value = " + envMap.get(key));
            }
    
            // getProperty方法返回的变量大多与java程序有关。Properties本质是HashTable
            Properties properties = System.getProperties();
            Set<String> nameSet = properties.stringPropertyNames();
            for(String name : nameSet){
                System.out.println("name = " + name + "  ||   value = " + properties.getProperty(name));
            }
        }
    }
    
    ----------------------------------------------
    日志输出
    name = java.runtime.name  ||   value = Java(TM) SE Runtime Environment
    name = sun.boot.library.path  ||   value = C:ThsSoftwareJDK8u144x64_thsjdkjrein
    name = java.vm.version  ||   value = 25.144-b01
    .......
    
    name = java.vm.specification.vendor  ||   value = Oracle Corporation
    name = user.variant  ||   value = 
    name = os.name  ||   value = Windows 7
    name = sun.jnu.encoding  ||   value = GBK

    END

  • 相关阅读:
    dotnet 使用 MessagePack 序列化对象
    dotnet 使用 MessagePack 序列化对象
    PHP die() 函数
    PHP defined() 函数
    PHP define() 函数
    PHP constant() 函数
    PHP connection_status() 函数
    查看物理CPU个数、核数、逻辑CPU个数
    CF997C Sky Full of Stars
    dotnet 使用 lz4net 压缩 Stream 或文件
  • 原文地址:https://www.cnblogs.com/wobuchifanqie/p/13645694.html
Copyright © 2020-2023  润新知