java.lang
Class System

java.lang.Object
  |
  +--java.lang.System

public final class System
extends Object

This Class provides a system-independent interface to system functionality. One of the more useful things provided by this Class are the standard input and output streams. The standard input streams are used for reading character data. The standard output streams are used for printing. For example:

	System.out.println("Hello World!");
 
This Class cannot be instantiated or subclassed because all of the methods and variables are static.


Field Summary
static PrintStream err
          Standard error stream.
static InputStream in
          Standard input stream.
static PrintStream out
          Standard output stream.
 
Method Summary
static void arraycopy(Object src, int src_position, Object dst, int dst_position, int length)
          Copies an array from the source array, beginning at the specified position, to the specified position of the destination array.
static long currentTimeMillis()
          Returns the current time in milliseconds GMT since the epoch (00:00:00 UTC, January 1, 1970).
static void exit(int status)
          Exits the virtual machine with an exit code.
static void gc()
          Runs the garbage collector.
static String getenv(String name)
          Obsolete.
static Properties getProperties()
          Gets the System properties.
static String getProperty(String key)
          Gets the System property indicated by the specified key.
static String getProperty(String key, String def)
          Gets the System property indicated by the specified key and def.
static SecurityManager getSecurityManager()
          Gets the system security interface.
static void load(String filename)
          Loads a dynamic library, given a complete path name.
static void loadLibrary(String libname)
          Loads a dynamic library with the specified library name.
static void runFinalization()
          Runs the finalization methods of any objects pending finalization.
static void setProperties(Properties props)
          Sets the System properties to the specified properties.
static void setSecurityManager(SecurityManager s)
          Sets the System security.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

public static InputStream in
Standard input stream. This stream is used for reading in character data.


out

public static PrintStream out
Standard output stream. This stream is used for printing messages.


err

public static PrintStream err
Standard error stream. This stream can be used to print error messages. Many applications read in data from an InputStream and output messages via the PrintStream out statement. Often applications rely on command line redirection to specify source and destination files. A problem with redirecting standard output is the incapability of writing messages to the screen if the output has been redirected to a file. This problem can be overcome by sending some output to PrintStream out and other output to PrintStream err. The difference between PrintStream err and PrintStream out is that PrintStream err is often used for displaying error messages but may be used for any purpose.

Method Detail

setSecurityManager

public static void setSecurityManager(SecurityManager s)
Sets the System security. This value can only be set once.

Parameters:
s - the security manager
Throws:
SecurityException - If the SecurityManager has already been set.

getSecurityManager

public static SecurityManager getSecurityManager()
Gets the system security interface.


currentTimeMillis

public static long currentTimeMillis()
Returns the current time in milliseconds GMT since the epoch (00:00:00 UTC, January 1, 1970). It is a signed 64 bit integer, and so it will not overflow until the year 292280995.

See Also:
Date

arraycopy

public static void arraycopy(Object src,
                             int src_position,
                             Object dst,
                             int dst_position,
                             int length)
Copies an array from the source array, beginning at the specified position, to the specified position of the destination array. This method does not allocate memory for the destination array. The memory must already be allocated.

Parameters:
src - the source data
length - the number of array elements to be copied
Throws:
ArrayIndexOutOfBoundsException - If copy would cause access of data outside array bounds.
ArrayStoreException - If an element in the src array could could not be stored into the destination array due to a type mismatch

getProperties

public static Properties getProperties()
Gets the System properties.


setProperties

public static void setProperties(Properties props)
Sets the System properties to the specified properties.

Parameters:
props - the properties to be set

getProperty

public static String getProperty(String key)
Gets the System property indicated by the specified key.

Parameters:
key - the name of the system property

getProperty

public static String getProperty(String key,
                                 String def)
Gets the System property indicated by the specified key and def.

Parameters:
key - the name of the system property
def - the default value to use if this property is not set

getenv

public static String getenv(String name)
Obsolete. Gets an environment variable. An environment variable is a system dependent external variable that has a string value.

Parameters:
name - the name of the environment variable
Returns:
the value of the variable, or null if the variable is not defined.

exit

public static void exit(int status)
Exits the virtual machine with an exit code. This method does not return, use with caution.

Parameters:
status - exit status, 0 if successful, other values indicate various error types.
See Also:
Runtime.exit(int)

gc

public static void gc()
Runs the garbage collector.

See Also:
Runtime.gc()

runFinalization

public static void runFinalization()
Runs the finalization methods of any objects pending finalization.

See Also:
Runtime.gc()

load

public static void load(String filename)
Loads a dynamic library, given a complete path name.

Parameters:
filename - the file to load
Throws:
UnsatisfiedLinkError - If the file does not exist.
See Also:
Runtime.load(java.lang.String)

loadLibrary

public static void loadLibrary(String libname)
Loads a dynamic library with the specified library name.

Parameters:
libname - the name of the library
Throws:
UnsatisfiedLinkError - If the library does not exist.
See Also:
Runtime.loadLibrary(java.lang.String)