Java.lang.System Class

Advertisements


Introduction

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

  • standard output

  • error output streams

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

  • A utility method for quickly copying a portion of an array.

  • a means of loading files and libraries

Class declaration

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

public 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

S.N.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<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 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.

Methods inherited

This class inherits methods from the following classes:

  • java.lang.Object




Advertisements
Advertisements