The System class holds a collection of static methods and variables. The standard input,
output, and error output of the Java run time are stored in the in, out, and err variables.
The methods defined by System are shown in Table 16-13. Many of the methods throw
a SecurityException if the operation is not permitted by the security manager.
Let's look at some common uses of System.
static void arraycopy(Object source,
Copies an array. The array to be copied is passed
int sourceStar t,
in source, and the index at which point the copy will
Object target,
begin within source is passed in sourceStar t. The
int targetStar t,
array that will receive the copy is passed in target,
int size)
and the index at which point the copy will begin
within target is passed in targetStar t. size is the
number of elements that are copied.
static String clearProper ty(String which)
Deletes the environmental variable specified by
which. The previous value associated with which
is returned.
static Console console ( )
Returns the console associated with the JVM. null is
returned if the JVM currently has no console. (Added
by Java SE 6.)
static long currentTimeMillis( )
Returns the current time in terms of milliseconds
since midnight, Januar y 1, 1970.
static void exit(int exitCode)
Halts execution and returns the value of exitCode to
the parent process (usually the operating system).
By convention, 0 indicates normal termination. All
other values indicate some form of error.
static void gc( )
Initiates garbage collection.
static Map<String, String> getenv( )
Returns a Map that contains the current environmental
variables and their values.
static String getenv(String which)
Returns the value associated with the environmental
variable passed in which.
static Proper ties getProper ties( )
Returns the proper ties associated with the Java
run-time system. (The Proper ties class is described
in Chapter 17.)
static String getProper ty(String which)
Returns the proper ty associated with which. A null
object is returned if the desired proper ty is not found.
static String getProper ty(String which,
Returns the proper ty associated with which. If the
String default)
desired proper ty is not found, default is returned.
static SecurityManager
Returns the current security manager or a null
getSecurityManager( )
object if no security manager is installed.
static int identityHashCode(Object obj)
Returns the identity hash code for obj.
TABLE 16-13
The Methods Defined by System
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks