java::io::System Class Reference

Inheritance diagram for java::io::System:

Inheritance graph
java::lang::Object
[legend]
Collaboration diagram for java::io::System:

Collaboration graph
java::lang::Object
[legend]

List of all members.


Detailed Description

The System class contains several useful class fields and methods.

It cannot be instantiated.

Among the facilities provided by the System class are standard input, standard output, and error output streams; access to externally defined "properties"; a means of loading files and libraries; and a utility method for quickly copying a portion of an array.

Author:
Arthur van Hoff
Version:
1.73, 07/01/98
Since:
JDK1.0

Static Public Member Functions

static jlong currentTimeMillis ()
 Returns the current time in milliseconds.
static jint indentityHashCode (const Object &x)
 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().
static Ref< PropertiesgetProperties ()
 Determines the current system properties.
static void setProperties (const Ref< Properties > &props)
 Sets the system properties to the Properties argument.
static Ref< StringgetProperty (const Ref< String > &key, const Ref< String > &defaultValue=0)
 Gets the system property indicated by the specified key.
static Ref< StringsetProperty (const Ref< String > &key, const Ref< String > &value)
 Sets the system property indicated by the specified key.
static void exit (jint status)
 Terminates the currently running Java Virtual Machine.
static EntryProc setEntryProc (EntryProc proc)
 Set the Main Entry Procedure here for System to invoke.
static void loadLibrary (const String &libname)
 Loads the system library specified by the libname argument.

Static Public Attributes

static Ref< InputStreamin
 The "standard" input stream.
static Ref< PrintStreamout
 The "standard" output stream.
static Ref< PrintStreamerr
 The "standard" error output stream.

Member Function Documentation

static jlong java::io::System::currentTimeMillis (  )  [static]

Returns the current time in milliseconds.

See the description of the class Date for a discussion of slight discrepancies that may arise between "computer time" and coordinated universal time (UTC).

Returns:
the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
See also:
java.util.Date
Since:
JDK1.0

static jint java::io::System::indentityHashCode ( const Object x  )  [static]

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

The hash code for the null reference is zero.

Parameters:
x object for which the hashCode is to be calculated
Returns:
the hashCode
Since:
JDK1.1

static Ref<Properties> java::io::System::getProperties (  )  [static]

Determines the current system properties.

First, if there is a security manager, its checkPropertiesAccess method is called with no arguments. This may result in a security exception.

The current set of system properties for use by the getProperty(String) method is returned as a Properties object. If there is no current set of system properties, a set of system properties is first created and initialized. This set of system properties always includes values for the following keys:
Key Description of Associated Value
java.version Java Runtime Environment version
java.vendor Java Runtime Environment vendor</tr
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version Java Virtual Machine specification version
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.name Java Virtual Machine specification name
java.vm.version Java Virtual Machine implementation version
java.vm.vendor Java Virtual Machine implementation vendor
java.vm.name Java Virtual Machine implementation name
java.specification.version Java Runtime Environment specification version
java.specification.vendor Java Runtime Environment specification vendor
java.specification.name Java Runtime Environment specification name
java.class.version Java class format version number
java.class.path Java class path
java.library.path List of paths to search when loading libraries
java.io.tmpdir Default temp file path
java.compiler Name of JIT compiler to use
java.ext.dirs Path of extension directory or directories
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("\n" on UNIX)
user.name User's account name
user.home User's home directory
user.dir User's current working directory

Multiple paths in a system property value are separated by the path separator character of the platform.

Note that even if the security manager does not permit the getProperties operation, it may choose to permit the getProperty(String) operation.

Returns:
the system properties
Exceptions:
SecurityException if a security manager exists and its checkPropertiesAccess method doesn't allow access to the system properties.
See also:
setProperties

java.lang.SecurityException

java.lang.SecurityManager::checkPropertiesAccess()

java.util.Properties

static void java::io::System::setProperties ( const Ref< Properties > &  props  )  [static]

Sets the system properties to the Properties argument.

First, if there is a security manager, its checkPropertiesAccess method is called with no arguments. This may result in a security exception.

The argument becomes the current set of system properties for use by the getProperty(String) method. If the argument is null, then the current set of system properties is forgotten.

Parameters:
props the new system properties.
Exceptions:
SecurityException if a security manager exists and its checkPropertiesAccess method doesn't allow access to the system properties.
See also:
getProperties

java.util.Properties

java.lang.SecurityException

java.lang.SecurityManager::checkPropertiesAccess()

static Ref<String> java::io::System::getProperty ( const Ref< String > &  key,
const Ref< String > &  defaultValue = 0 
) [static]

Gets the system property indicated by the specified key.

First, if there is a security manager, its checkPropertyAccess method is called with the key as its argument.

If there is no current set of system properties, a set of system properties is first created and initialized in the same manner as for the getProperties method.

Parameters:
key the name of the system property.
def a default value.
Returns:
the string value of the system property, or the default value if there is no property with that key.
Exceptions:
SecurityException if a security manager exists and its checkPropertyAccess method doesn't allow access to the specified system property.
NullPointerException if key is null.
IllegalArgumentException if key is empty.
See also:
setProperty

java.lang.SecurityManager::checkPropertyAccess(java.lang.String)

java.lang.System::getProperties()

static Ref<String> java::io::System::setProperty ( const Ref< String > &  key,
const Ref< String > &  value 
) [static]

Sets the system property indicated by the specified key.

First, if a security manager exists, its SecurityManager.checkPermission method is called with a PropertyPermission(key, "write") permission. This may result in a SecurityException being thrown. If no exception is thrown, the specified property is set to the given value.

Parameters:
key the name of the system property.
value the value of the system property.
Returns:
the previous value of the system property, or null if it did not have one.
Exceptions:
SecurityException if a security manager exists and its checkPermission method doesn't allow setting of the specified property.
NullPointerException if key is null.
IllegalArgumentException if key is empty.
See also:
getProperty

java.lang.System::getProperty(java.lang.String)

java.lang.System::getProperty(java.lang.String, java.lang.String)

java.util.PropertyPermission

SecurityManager::checkPermission

Since:
1.2

static void java::io::System::exit ( jint  status  )  [static]

Terminates the currently running Java Virtual Machine.

The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination.

This method calls the exit method in class Runtime. This method never returns normally.

The call System.exit(n) is effectively equivalent to the call: <blockquote>

 Runtime.getRuntime().exit(n)
 
</blockquote>

Parameters:
status exit status.
Exceptions:
SecurityException if a security manager exists and its checkExit method doesn't allow exit with the specified status.
See also:
java.lang.Runtime::exit(int)

static EntryProc java::io::System::setEntryProc ( EntryProc  proc  )  [static]

Set the Main Entry Procedure here for System to invoke.

static void java::io::System::loadLibrary ( const String libname  )  [static]

Loads the system library specified by the libname argument.

The manner in which a library name is mapped to the actual system library is system dependent.

The call System.loadLibrary(name) is effectively equivalent to the call <blockquote>

 Runtime.getRuntime().loadLibrary(name)
 
</blockquote>

Parameters:
libname the name of the library.
Exceptions:
SecurityException if a security manager exists and its checkLink method doesn't allow loading of the specified dynamic library
UnsatisfiedLinkError if the library does not exist.
See also:
java.lang.Runtime::loadLibrary(java.lang.String)

java.lang.SecurityManager::checkLink(java.lang.String)


Member Data Documentation

Ref<InputStream> java::io::System::in [static]

The "standard" input stream.

This stream is already open and ready to supply input data. Typically this stream corresponds to keyboard input or another input source specified by the host environment or user.

Ref<PrintStream> java::io::System::out [static]

The "standard" output stream.

This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output destination specified by the host environment or user.

For simple stand-alone Java applications, a typical way to write a line of output data is: <blockquote>

     System.out.println(data)
 
</blockquote>

See the println methods in class PrintStream.

Ref<PrintStream> java::io::System::err [static]

The "standard" error output stream.

This stream is already open and ready to accept output data.

Typically this stream corresponds to display output or another output destination specified by the host environment or user. By convention, this output stream is used to display error messages or other information that should come to the immediate attention of a user even if the principal output stream, the value of the variable out, has been redirected to a file or other destination that is typically not continuously monitored.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:33 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3