| public final class java.lang System
|
Java SE 6 |
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 and environment
variables; a means of loading files and libraries; and a utility
method for quickly copying a portion of an array.
| version | 1.158, 03/13/06 |
| since | JDK1.0 |
| Fields | |||
|---|---|---|---|
| final public static InputStream | in 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. | ||
| final public static PrintStream | out Details
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:
See the
| ||
| final public static PrintStream | err 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 | ||
| Methods | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public static void | arraycopy(Object src, int srcPos, Object dest, int destPos, int length) Details
Copies an array from the specified source array, beginning at the
specified position, to the specified position of the destination array.
A subsequence of array components are copied from the source
array referenced by src to the destination array
referenced by dest. The number of components copied is
equal to the length argument. The components at
positions srcPos through
srcPos+length-1 in the source array are copied into
positions destPos through
destPos+length-1, respectively, of the destination
array.
If the
If
If
Otherwise, if any of the following is true, an
Otherwise, if any of the following is true, an
Otherwise, if any actual component of the source array from
position
| ||||||||||||||||
| public static String | clearProperty(String key) Details
Removes the system property indicated by the specified key.
First, if a security manager exists, its
| ||||||||||||||||
| public static Console | console() Details
Returns the unique Console object associated
with the current Java virtual machine, if any.
| ||||||||||||||||
| public static long | currentTimeMillis() Details
Returns the current time in milliseconds. Note that
while the unit of time of the return value is a millisecond,
the granularity of the value depends on the underlying
operating system and may be larger. For example, many
operating systems measure time in units of tens of
milliseconds.
See the description of the class
| ||||||||||||||||
| public static void | exit(int status) Details
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
The call Runtime.getRuntime().exit(n)
| ||||||||||||||||
| public static void | gc() Details
Runs the garbage collector.
Calling the
The call Runtime.getRuntime().gc()
| ||||||||||||||||
| public static int | identityHashCode(Object x) Details
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.
| ||||||||||||||||
| public static Channel | inheritedChannel() throws IOException Details
Returns the channel inherited from the entity that created this
Java virtual machine.
This method returns the channel obtained by invoking the
In addition to the network-oriented channels described in
| ||||||||||||||||
| public static void | load(String filename) Details
Loads a code file with the specified filename from the local file
system as a dynamic library. The filename
argument must be a complete path name.
The call Runtime.getRuntime().load(name)
| ||||||||||||||||
| public static void | loadLibrary(String libname) Details
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 Runtime.getRuntime().loadLibrary(name)
| ||||||||||||||||
| public static String | mapLibraryName(String libname) Details
Maps a library name into a platform-specific string representing
a native library.
| ||||||||||||||||
| public static long | nanoTime() Details
Returns the current value of the most precise available system
timer, in nanoseconds.
This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary time (perhaps in the future, so values may be negative). This method provides nanosecond precision, but not necessarily nanosecond accuracy. No guarantees are made about how frequently values change. Differences in successive calls that span greater than approximately 292 years (263 nanoseconds) will not accurately compute elapsed time due to numerical overflow. For example, to measure how long some code takes to execute: long startTime = System.nanoTime(); // ... the code being measured ... long estimatedTime = System.nanoTime() - startTime;
| ||||||||||||||||
| public static void | runFinalization() Details
Runs the finalization methods of any objects pending finalization.
Calling this method suggests that the Java Virtual Machine expend
effort toward running the
The call Runtime.getRuntime().runFinalization()
| ||||||||||||||||
| public static void | runFinalizersOnExit(boolean value) Details
Enable or disable finalization on exit; doing so specifies that the
finalizers of all objects that have finalizers that have not yet been
automatically invoked are to be run before the Java runtime exits.
By default, finalization on exit is disabled.
If there is a security manager,
its
| ||||||||||||||||
| Properties | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| public static String | getenv(String name) Details
Gets the value of the specified environment variable. An
environment variable is a system-dependent external named
value.
If a security manager exists, its
System
properties and environment variables are both
conceptually mappings between names and values. Both
mechanisms can be used to pass user-defined information to a
Java process. Environment variables have a more global effect,
because they are visible to all descendants of the process
which defines them, not just the immediate Java subprocess.
They can have subtly different semantics, such as case
insensitivity, on different operating systems. For these
reasons, environment variables are more likely to have
unintended side effects. It is best to use system properties
where possible. Environment variables should be used when a
global effect is desired, or when an external system interface
requires an environment variable (such as On UNIX systems the alphabetic case of
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static Map | getenv() Details
Returns an unmodifiable string map view of the current system environment.
The environment is a system-dependent mapping from names to
values which is passed from parent to child processes.
If the system does not support environment variables, an empty map is returned. The returned map will never contain null keys or values.
Attempting to query the presence of a null key or value will
throw a The returned map and its collection views may not obey the
general contract of the The returned map is typically case-sensitive on all platforms. If a security manager exists, its
When passing information to a Java subprocess, system properties are generally preferred over environment variables.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void | setErr(PrintStream err) Details
Reassigns the "standard" error output stream.
First, if there is a security manager, its
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void | setIn(InputStream in) Details
Reassigns the "standard" input stream.
First, if there is a security manager, its
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void | setOut(PrintStream out) Details
Reassigns the "standard" output stream.
First, if there is a security manager, its
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void | setProperties(Properties props) Details
Sets the system properties to the Properties
argument.
First, if there is a security manager, its
The argument becomes the current set of system properties for use
by the
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static Properties | getProperties() Details
Determines the current system properties.
First, if there is a security manager, its
The current set of system properties for use by the
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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static String | setProperty(String key, String value) Details
Sets the system property indicated by the specified key.
First, if a security manager exists, its
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static String | getProperty(String key) Details
Gets the system property indicated by the specified key.
First, if there is a security manager, its
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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static String | getProperty(String key, String def) Details
Gets the system property indicated by the specified key.
First, if there is a security manager, its
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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static void | setSecurityManager(SecurityManager s) Details
Sets the System security.
If there is a security manager already installed, this method first
calls the security manager's Otherwise, the argument is established as the current
security manager. If the argument is
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static SecurityManager | getSecurityManager() Details
Gets the system security interface.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| About DocWeb · Bundles · Export · Export All | Top 10 · Statistics · Login |
| About Sun · Contact · Privacy · Terms of Use · Trademarks | Java SE 6 · Copyright © 1994-2013 Sun Microsystems, Inc.All rights reserved. Use is subject to license terms |
![]() |
![]() |
|