java.lang.System Class Reference

List of all members.


Detailed Description

Class System provides a standard place for programs to find system related information.

All System API is static.

Static Public Member Functions

static void setIn (InputStream newIn)
 Sets the value of the static slot "in" in the receiver to the passed in argument.
static void setOut (java.io.PrintStream newOut)
 Sets the value of the static slot "out" in the receiver to the passed in argument.
static void setErr (java.io.PrintStream newErr)
 Sets the value of the static slot "err" in the receiver to the passed in argument.
static void arraycopy (Object array1, int start1, Object array2, int start2, int length)
 Copies the contents of array1 starting at offset start1 into array2 starting at offset start2 for length elements.
static native long currentTimeMillis ()
 Answers the current time expressed as milliseconds since the time 00:00:00 UTC on January 1, 1970.
static native long nanoTime ()
static void exit (int code)
 Causes the virtual machine to stop running, and the program to exit.
static void gc ()
 Indicate to the virtual machine that it would be a good time to collect available memory.
static String getenv (String var)
 Returns an environment variable.
static Map< String, String > getenv ()
static Channel inheritedChannel () throws IOException
static Properties getProperties ()
 Answers the system properties.
static String getProperty (String prop)
 Answers the value of a particular system property.
static String getProperty (String prop, String defaultValue)
 Answers the value of a particular system property.
static String setProperty (String prop, String value)
 Sets the value of a particular system property.
static String clearProperty (String key)
static SecurityManager getSecurityManager ()
 Answers the active security manager.
static native int identityHashCode (Object anObject)
 Answers an integer hash code for the parameter.
static void load (String pathName)
 Loads the specified file as a dynamic library.
static void loadLibrary (String libName)
 Loads and links the library specified by the argument.
static void runFinalization ()
 Provides a hint to the virtual machine that it would be useful to attempt to perform any outstanding object finalizations.
static void runFinalizersOnExit (boolean flag)
 Ensure that, when the virtual machine is about to exit, all objects are finalized.
static void setProperties (Properties p)
 Answers the system properties.
static void setSecurityManager (final SecurityManager s)
 Sets the active security manager.
static native String mapLibraryName (String userLibName)
 Answers the platform specific file name format for the shared library named by the argument.

Static Public Attributes

static final InputStream in
 Default input stream.
static final PrintStream out
 Default output stream.
static final PrintStream err
 Default error output stream.

Static Package Functions

 [static initializer]
static Properties internalGetProperties ()
 Answers the system properties without any security checks.

Private Member Functions

 System ()
 Prevents this class from being instantiated.

Static Private Member Functions

static void arraycopy (Object[] A1, int offset1, Object[] A2, int offset2, int length)
 Private version of the arraycopy method (used by the jit for reference arraycopies).
static void arraycopy (int[] A1, int offset1, int[] A2, int offset2, int length)
 Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.
static void arraycopy (byte[] A1, int offset1, byte[] A2, int offset2, int length)
 Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.
static void arraycopy (short[] A1, int offset1, short[] A2, int offset2, int length)
 Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.
static void arraycopy (long[] A1, int offset1, long[] A2, int offset2, int length)
 Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.
static void arraycopy (char[] A1, int offset1, char[] A2, int offset2, int length)
 Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.
static void arraycopy (boolean[] A1, int offset1, boolean[] A2, int offset2, int length)
 Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.
static void arraycopy (double[] A1, int offset1, double[] A2, int offset2, int length)
 Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.
static void arraycopy (float[] A1, int offset1, float[] A2, int offset2, int length)
 Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.
static void ensureProperties ()
 If systemProperties is unset, then create a new one based on the values provided by the virtual machine.
static native String[] getPropertyList ()
 Answers an array of Strings containing key.
static native String getEncoding (int type)
 Return the requested encoding.
static native void setFieldImpl (String fieldName, Object stream)
 Sets the value of the named static field in the receiver to the passed in argument.

Static Private Attributes

static final Runtime RUNTIME = Runtime.getRuntime()
static Properties systemProperties
static SecurityManager security
static boolean security_initialized
static final int InitLocale = 0
static final int PlatformEncoding = 1
static final int FileEncoding = 2
static final int OSEncoding = 3


Constructor & Destructor Documentation

java.lang.System.System (  )  [private]

Prevents this class from being instantiated.


Member Function Documentation

static void java.lang.System.setIn ( InputStream  newIn  )  [static]

Sets the value of the static slot "in" in the receiver to the passed in argument.

Parameters:
newIn the new value for in.

static void java.lang.System.setOut ( java.io.PrintStream  newOut  )  [static]

Sets the value of the static slot "out" in the receiver to the passed in argument.

Parameters:
newOut the new value for out.

static void java.lang.System.setErr ( java.io.PrintStream  newErr  )  [static]

Sets the value of the static slot "err" in the receiver to the passed in argument.

Parameters:
newErr the new value for err.

static void java.lang.System.arraycopy ( Object  array1,
int  start1,
Object  array2,
int  start2,
int  length 
) [static]

Copies the contents of array1 starting at offset start1 into array2 starting at offset start2 for length elements.

Parameters:
array1 the array to copy out of
start1 the starting index in array1
array2 the array to copy into
start2 the starting index in array2
length the number of elements in the array to copy

static void java.lang.System.arraycopy ( Object[]  A1,
int  offset1,
Object[]  A2,
int  offset2,
int  length 
) [static, private]

Private version of the arraycopy method (used by the jit for reference arraycopies).

static void java.lang.System.arraycopy ( int[]  A1,
int  offset1,
int[]  A2,
int  offset2,
int  length 
) [static, private]

Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.

Parameters:
A1 the array to copy out of
offset1 the starting index in array1
A2 the array to copy into
offset2 the starting index in array2
length the number of elements in the array to copy

static void java.lang.System.arraycopy ( byte[]  A1,
int  offset1,
byte[]  A2,
int  offset2,
int  length 
) [static, private]

Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.

Parameters:
A1 the array to copy out of
offset1 the starting index in array1
A2 the array to copy into
offset2 the starting index in array2
length the number of elements in the array to copy

static void java.lang.System.arraycopy ( short[]  A1,
int  offset1,
short[]  A2,
int  offset2,
int  length 
) [static, private]

Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.

Parameters:
A1 the array to copy out of
offset1 the starting index in array1
A2 the array to copy into
offset2 the starting index in array2
length the number of elements in the array to copy

static void java.lang.System.arraycopy ( long[]  A1,
int  offset1,
long[]  A2,
int  offset2,
int  length 
) [static, private]

Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.

Parameters:
A1 the array to copy out of
offset1 the starting index in array1
A2 the array to copy into
offset2 the starting index in array2
length the number of elements in the array to copy

static void java.lang.System.arraycopy ( char[]  A1,
int  offset1,
char[]  A2,
int  offset2,
int  length 
) [static, private]

Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.

Parameters:
A1 the array to copy out of
offset1 the starting index in array1
A2 the array to copy into
offset2 the starting index in array2
length the number of elements in the array to copy

static void java.lang.System.arraycopy ( boolean[]  A1,
int  offset1,
boolean[]  A2,
int  offset2,
int  length 
) [static, private]

Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.

Parameters:
A1 the array to copy out of
offset1 the starting index in array1
A2 the array to copy into
offset2 the starting index in array2
length the number of elements in the array to copy

static void java.lang.System.arraycopy ( double[]  A1,
int  offset1,
double[]  A2,
int  offset2,
int  length 
) [static, private]

Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.

Parameters:
A1 the array to copy out of
offset1 the starting index in array1
A2 the array to copy into
offset2 the starting index in array2
length the number of elements in the array to copy

static void java.lang.System.arraycopy ( float[]  A1,
int  offset1,
float[]  A2,
int  offset2,
int  length 
) [static, private]

Copies the contents of A1 starting at offset offset1 into A2 starting at offset offset2 for length elements.

Parameters:
A1 the array to copy out of
offset1 the starting index in array1
A2 the array to copy into
offset2 the starting index in array2
length the number of elements in the array to copy

static native long java.lang.System.currentTimeMillis (  )  [static]

Answers the current time expressed as milliseconds since the time 00:00:00 UTC on January 1, 1970.

Returns:
the time in milliseconds.

static native long java.lang.System.nanoTime (  )  [static]

Returns the most precise time measurement in nanoseconds that's available.

Returns:
The current time in nanoseconds.

static void java.lang.System.ensureProperties (  )  [static, private]

If systemProperties is unset, then create a new one based on the values provided by the virtual machine.

static void java.lang.System.exit ( int  code  )  [static]

Causes the virtual machine to stop running, and the program to exit.

If runFinalizersOnExit(true) has been invoked, then all finalizers will be run first.

Parameters:
code the return code.
Exceptions:
SecurityException if the running thread is not allowed to cause the vm to exit.
See also:
SecurityManager.checkExit

static void java.lang.System.gc (  )  [static]

Indicate to the virtual machine that it would be a good time to collect available memory.

Note that, this is a hint only.

static String java.lang.System.getenv ( String  var  )  [static]

Returns an environment variable.

Parameters:
var the name of the environment variable
Returns:
the value of the specified environment variable

static Map<String, String> java.lang.System.getenv (  )  [static]

Returns all environment variables.

Returns:
A Map of all environment variables.

static Channel java.lang.System.inheritedChannel (  )  throws IOException [static]

Returns the inherited channel from the system-wide provider.

Returns:
A Channel or null.
Exceptions:
IOException 
See also:
SelectorProvider

SelectorProvider.inheritedChannel()

static Properties java.lang.System.getProperties (  )  [static]

Answers the system properties.

Note that this is not a copy, so that changes made to the returned Properties object will be reflected in subsequent calls to getProperty and getProperties.

Security managers should restrict access to this API if possible.

Returns:
the system properties

static Properties java.lang.System.internalGetProperties (  )  [static, package]

Answers the system properties without any security checks.

This is used for access from within java.lang.

Returns:
the system properties

static String java.lang.System.getProperty ( String  prop  )  [static]

Answers the value of a particular system property.

Answers null if no such property exists,

The properties currently provided by the virtual machine are:

        java.vendor.url
        java.class.path
        user.home
        java.class.version
        os.version
        java.vendor
        user.dir
        user.timezone
        path.separator
        os.name
        os.arch
        line.separator
        file.separator
        user.name
        java.version
        java.home
 

Parameters:
prop the system property to look up
Returns:
the value of the specified system property, or null if the property doesn't exist

static String java.lang.System.getProperty ( String  prop,
String  defaultValue 
) [static]

Answers the value of a particular system property.

If no such property is found, answers the defaultValue.

Parameters:
prop the system property to look up
defaultValue return value if system property is not found
Returns:
the value of the specified system property, or defaultValue if the property doesn't exist

static String java.lang.System.setProperty ( String  prop,
String  value 
) [static]

Sets the value of a particular system property.

Parameters:
prop the system property to change
value the value to associate with prop
Returns:
the old value of the property, or null

static String java.lang.System.clearProperty ( String  key  )  [static]

Removes the system property for the specified key.

Please see the Java SE API documentation for further information on this method.

Parameters:
key the system property to be removed.
Returns:
previous value or null if no value existed
Exceptions:
NullPointerException if the key argument is null.
IllegalArgumentException if the key argument is empty.
SecurityException if a security manager exists and write access to the specified property is not allowed.
Since:
1.5

static native String [] java.lang.System.getPropertyList (  )  [static, private]

Answers an array of Strings containing key.

.value pairs (in consecutive array elements) which represent the starting values for the system properties as provided by the virtual machine.

Returns:
the default values for the system properties.

static native String java.lang.System.getEncoding ( int  type  )  [static, private]

Return the requested encoding.

0 - initialize locale 1 - detected platform encoding 2 - command line defined file.encoding 3 - command line defined os.encoding

static SecurityManager java.lang.System.getSecurityManager (  )  [static]

Answers the active security manager.

Returns:
the system security manager object.

static native int java.lang.System.identityHashCode ( Object  anObject  )  [static]

Answers an integer hash code for the parameter.

The hash code returned is the same one that would be returned by java.lang.Object.hashCode(), whether or not the object's class has overridden hashCode(). The hash code for null is 0.

Parameters:
anObject the object
Returns:
the hash code for the object
See also:
java.lang.Object.hashCode

static void java.lang.System.load ( String  pathName  )  [static]

Loads the specified file as a dynamic library.

Parameters:
pathName the path of the file to be loaded

static void java.lang.System.loadLibrary ( String  libName  )  [static]

Loads and links the library specified by the argument.

Parameters:
libName the name of the library to load
Exceptions:
UnsatisfiedLinkError if the library could not be loaded
SecurityException if the library was not allowed to be loaded

static void java.lang.System.runFinalization (  )  [static]

Provides a hint to the virtual machine that it would be useful to attempt to perform any outstanding object finalizations.

static void java.lang.System.runFinalizersOnExit ( boolean  flag  )  [static]

Ensure that, when the virtual machine is about to exit, all objects are finalized.

Note that all finalization which occurs when the system is exiting is performed after all running threads have been terminated.

Parameters:
flag true means finalize all on exit.
Deprecated:
This method is unsafe.

static void java.lang.System.setProperties ( Properties  p  )  [static]

Answers the system properties.

Note that the object which is passed in not copied, so that subsequent changes made to the object will be reflected in calls to getProperty and getProperties.

Security managers should restrict access to this API if possible.

Parameters:
p the property to set

static void java.lang.System.setSecurityManager ( final SecurityManager  s  )  [static]

Sets the active security manager.

Note that once the security manager has been set, it can not be changed. Attempts to do so will cause a security exception.

Parameters:
s the new security manager
Exceptions:
SecurityException if the security manager has already been set.

static native String java.lang.System.mapLibraryName ( String  userLibName  )  [static]

Answers the platform specific file name format for the shared library named by the argument.

Parameters:
userLibName the name of the library to look up.
Returns:
the platform specific filename for the library

static native void java.lang.System.setFieldImpl ( String  fieldName,
Object  stream 
) [static, private]

Sets the value of the named static field in the receiver to the passed in argument.

Parameters:
fieldName the name of the field to set, one of in, out, or err
stream the new value of the field


Member Data Documentation

final InputStream java.lang.System.in [static]

Default input stream.

final PrintStream java.lang.System.out [static]

Default output stream.

final PrintStream java.lang.System.err [static]

Default error output stream.


The documentation for this class was generated from the following file:

Genereated on Tue Dec 9 14:09:48 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.