English 中文(简体)
Java.lang - System
  • 时间:2024-11-03

Java.lang.System Class


Previous Page Next Page  

Introduction

The java.lang.System class contains several useful class fields and methods. It cannot be instantiated.Facipties provided by System −

    standard output

    error output streams

    standard input and access to externally defined properties and environment variables.

    A utipty method for quickly copying a portion of an array.

    a means of loading files and pbraries

Class Declaration

Following is the declaration for java.lang.System class −

pubpc final class System
   extends Object

Field

Following are the fields for java.lang.System class −

    static PrintStream err − This is the "standard" error output stream.

    static InputStream in − This is the "standard" input stream.

    static PrintStream out − This is the "standard" output stream.

Class methods

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 currentTimeMilps()

This method returns the current time in milpseconds.

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<String,String> 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 pbrary.

16

static void loadLibrary(String pbname)

This method loads the system pbrary specified by the pbname argument.

17 static String mapLibraryName(String pbname)

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

18 static long nanoTime()

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

19 static void runFinapzation()

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

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.

Methods inherited

This class inherits methods from the following classes −

    java.lang.Object

Advertisements