博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
system getenv_Java System类getenv()方法及示例
阅读量:2534 次
发布时间:2019-05-11

本文共 2631 字,大约阅读时间需要 8 分钟。

system getenv

系统类getenv()方法 (System class getenv() method)

  • getenv() method is available in java.lang package.

    getenv()方法在java.lang包中可用。

  • getenv() method is used to return an unmodifiable Map of the current environment variable in key-value pairs.

    getenv()方法用于返回键值对中当前环境变量的不可修改Map。

  • We will see what is environment variable ? An environment variable is a system dependent external named value.

    我们将看到什么是环境变量? 环境变量是系统相关的外部命名值。

  • We should go for environment variable when a system interface needed an environment variable (such as PATH).

    当系统接口需要环境变量(例如PATH)时,我们应该选择环境变量。

  • When we assign the value of the environment variable then we don’t need to assign the value of the environment variable again while working.

    当我们分配环境变量的值时,我们就不需要在工作时再次分配环境变量的值。

  • getenv() method is a static method so it is accessible with the class name too.

    getenv()方法是静态方法,因此也可以使用类名进行访问。

  • getenv() method method may throw an exception at the time of retrieving the environment variable:

    getenv()方法 method可能在检索环境变量时引发异常:

    SecurityException: If a particular method checkPermission() does not allow access to the process environment when the security manager exists.

    SecurityException :如果存在安全管理器时,如果特定方法checkPermission()不允许访问流程环境。

Syntax:

句法:

public static Map getenv ();

Parameter(s):

参数:

  • This method does not accept any parameter.

    此方法不接受任何参数。

Return value:

返回值:

The return type of this method is Map, it returns the environment variable with the desired value.

此方法的返回类型为Map ,它返回具有所需值的环境变量。

Example:

例:

// Java program to demonstrate the example of // getenv() method of System Class.import java.util.*;import java.lang.*;public class GetenvMethod {
public static void main(String[] args) {
Map < String, String > map = System.getenv(); // By using keyset() method is used to iterate Set < String > system_keys = map.keySet(); for (String keys: system_keys) {
System.out.println("system_key= " + keys); String values = map.get(keys); System.out.println("system_key_value= " + values); } }}

Output

输出量

E:\Programs>javac GetenvMethod.javaE:\Programs>java GetenvMethodsystem_key= PATHsystem_key_value= /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-10-jdk/binsystem_key= SHELLsystem_key_value= /bin/bashsystem_key= HOSTNAMEsystem_key_value= jdoodlesystem_key= JAVA_OPTSsystem_key_value= --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMEDsystem_key= PWDsystem_key_value= /homesystem_key= SHLVLsystem_key_value= 1system_key= HOMEsystem_key_value= /rootsystem_key= _system_key_value= /usr/bin/time

翻译自:

system getenv

转载地址:http://fnxzd.baihongyu.com/

你可能感兴趣的文章
Hdu【线段树】基础题.cpp
查看>>
时钟系统
查看>>
BiTree
查看>>
5个基于HTML5的加载动画推荐
查看>>
水平权限漏洞的修复方案
查看>>
静态链接与动态链接的区别
查看>>
Android 关于悬浮窗权限的问题
查看>>
如何使用mysql
查看>>
linux下wc命令详解
查看>>
敏捷开发中软件测试团队的职责和产出是什么?
查看>>
在mvc3中使用ffmpeg对上传视频进行截图和转换格式
查看>>
python的字符串内建函数
查看>>
Spring - DI
查看>>
微软自己的官网介绍 SSL 参数相关
查看>>
Composite UI Application Block (CAB) 概念和术语
查看>>
ajax跨域,携带cookie
查看>>
阶段3 2.Spring_01.Spring框架简介_03.spring概述
查看>>
阶段3 2.Spring_02.程序间耦合_1 编写jdbc的工程代码用于分析程序的耦合
查看>>
阶段3 2.Spring_01.Spring框架简介_04.spring发展历程
查看>>
阶段3 2.Spring_02.程序间耦合_3 程序的耦合和解耦的思路分析1
查看>>