📜  Java.lang.System类

📅  最后修改于: 2020-11-15 03:09:06             🧑  作者: Mango


介绍

java.lang.System类包含几个有用的类字段和方法。无法实例化系统提供的功能-

  • 标准输出

  • 错误输出流

  • 标准输入和对外部定义的属性和环境变量的访问。

  • 一种用于快速复制数组一部分的实用方法。

  • 一种加载文件和库的方法

类声明

以下是java.lang.System类的声明-

public final class System
   extends Object

领域

以下是java.lang.System类的字段-

  • 静态PrintStream err-这是“标准”错误输出流。

  • 静态InputStream in-这是“标准”输入流。

  • 静态PrintStream输出-这是“标准”输出流。

类方法

Sr.No. Method & Description
1 static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)

This method copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array.

2 static String clearProperty(String key)

This method removes the system property indicated by the specified key.

3 static Console console()

This method returns the unique Console object associated with the current Java virtual machine, if any.

4 static long currentTimeMillis()

This method returns the current time in milliseconds.

5 static void exit(int status)

This method terminates the currently running Java Virtual Machine.

6 static void gc()

This method runs the garbage collector.

7

static Map getenv()

This method returns an unmodifiable string map view of the current system environment.

8 static String getenv(String name)

This method gets the value of the specified environment variable.

9 static Properties getProperties()

This method determines the current system properties.

10 static String getProperty(String key)

This method gets the system property indicated by the specified key.

11 static String getProperty(String key, String def)

This method gets the system property indicated by the specified key.

12 static SecurityManager getSecurityManager()

This method gets the system security interface.

13 static int identityHashCode(Object x)

This method returns the same hash code for the given object as would be returned by the default method hashCode(), whether or not the given object's class overrides hashCode().

14

static Channel inheritedChannel()

This method returns the channel inherited from the entity that created this Java virtual machine.

15 static void load(String filename)

This method loads a code file with the specified filename from the local file system as a dynamic library.

16

static void loadLibrary(String libname)

This method loads the system library specified by the libname argument.

17 static String mapLibraryName(String libname)

This method maps a library name into a platform-specific string representing a native library.

18 static long nanoTime()

This method returns the current value of the most precise available system timer, in nanoseconds.

19 static void runFinalization()

This method runs the finalization methods of any objects pending finalization.

20 static void setErr(PrintStream err)

This method reassigns the "standard" error output stream.

21 static void setIn(InputStream in)

This method reassigns the "standard" input stream.

22 static void setOut(PrintStream out)

This method reassigns the "standard" output stream.

23 static void setProperties(Properties props)

This method sets the system properties to the Properties argument.

24 static String setProperty(String key, String value)

This method sets the system property indicated by the specified key.

25

static void setSecurityManager(SecurityManager s)

This method sets the System security.

方法继承

此类从以下类继承方法-

  • java.lang.Object