Class java.lang.System
All Packages    This Package    Previous    Next

Class java.lang.System

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

public final class System
extends Object
This class provides access to system functionality. One of the more useful things provided by this class are the standard i/o streams. They are used to do printing. For example:
	System.out.println("Hello World!");
Version:
1.21, 02 Feb 1995
Author:
Arthur van Hoff

err
Standard error stream.
in
Standard input stream.
out
Standard output stream.

arraycopy(boolean[], int, boolean[], int, int)
Copies an array of booleans.
arraycopy(byte[], int, byte[], int, int)
Copies an array of bytes.
arraycopy(char[], int, char[], int, int)
Copies an array of characters.
arraycopy(short[], int, short[], int, int)
Copies an array of shorts.
arraycopy(int[], int, int[], int, int)
Copies an array of integers.
arraycopy(long[], int, long[], int, int)
Copies an array of longs.
arraycopy(float[], int, float[], int, int)
Copies an array of floats.
arraycopy(double[], int, double[], int, int)
Copies an array of doubles.
arraycopy(Object[], int, Object[], int, int)
Copies an array of objects.
currentTime()
Returns the current time in seconds GMT since the epoch (currently undefined).
dumpMon(Object)
Dumps the state of all monitors.
dumpProfile()
Dumps profiling data.
exec(String)
Executes a system command.
execin(String)
Executes a system command.
execout(String)
Executes a system command.
exit(int)
Exits the interpreter with an exit code.
freeMemory()
Returns number of free bytes in system memory.
gc()
Runs the garbage collector.
getCWD()
Get the current working directory.
getOSName()
Get the name of the operating system.
getenv(String)
Gets an environment variable.
nowMillis()
Returns the current time in milliseconds.
profile(int)
Enables/Disables profiling of method calls.
runFinalization()
Runs the finalization methods of any objects pending finalization.
totalMemory()
Returns the total number of bytes in system memory.
traceInstructions(int)
Enables/Disables tracing of instructions.
traceMethodCalls(int)
Enables/Disables tracing of method calls.

in
  public static InputStream in
Standard input stream.
out
  public static PrintStream out
Standard output stream. This stream lets you print messages.
err
  public static PrintStream err
Standard error stream. This stream can be used to print error messages.

nowMillis
  public static int nowMillis()
Returns the current time in milliseconds.
Returns:
the time in milliseconds
See Also:
Date

currentTime

  public static int currentTime()
Returns the current time in seconds GMT since the epoch (currently undefined). Use this for times that need to be compared. For times that need to be printed, use java.util.Date instead.
See Also:
Date

freeMemory

  public static int freeMemory()
Returns number of free bytes in system memory. This number is not always accurate.
Returns:
bytes free in system memory

totalMemory

  public static int totalMemory()
Returns the total number of bytes in system memory.
Returns:
bytes in system memory

gc

  public static void gc()
Runs the garbage collector. Usually it is not necessary to call this method since there is an asynchronous garbage collector which runs whenever the system is idle. The garbage collector also runs automatically when object allocation fails.

runFinalization

  public static void runFinalization()
Runs the finalization methods of any objects pending finalization. Usually it is not necessary to call this method since finalization methods will be called asynchronously by a finalization thread. However, because finalized resources are of the user's choosing, there is no built-in equivalent of the garbage collector running when the system runs out of memory. With runFinalization(), users can build equivalent functionality into their resource allocators.

arraycopy

  public static void arraycopy(boolean src[],
                               int srcpos,
                               boolean dest[],
                               int destpos,
                               int length)
Copies an array of booleans.
Parameters:
src - the source data
srcpos - start position in the source data
dest - the destination
destpos - start position in the destination data
length - length of the data to be copied
Throws: ArrayIndexOutOfBoundsException
Copy would cause access of data outside array bounds

arraycopy

  public static void arraycopy(byte src[],
                               int srcpos,
                               byte dest[],
                               int destpos,
                               int length)
Copies an array of bytes.
Parameters:
src - the source data
srcpos - start position in the source data
dest - the destination
destpos - start position in the destination data
length - length of the data to be copied
Throws: ArrayIndexOutOfBoundsException
Copy would cause access of data outside array bounds

arraycopy

  public static void arraycopy(char src[],
                               int srcpos,
                               char dest[],
                               int destpos,
                               int length)
Copies an array of characters.
Parameters:
src - the source data
srcpos - start position in the source data
dest - the destination
destpos - start position in the destination data
length - length of the data to be copied
Throws: ArrayIndexOutOfBoundsException
Copy would cause access of data outside array bound

arraycopy

  public static void arraycopy(short src[],
                               int srcpos,
                               short dest[],
                               int destpos,
                               int length)
Copies an array of shorts.
Parameters:
src - the source data
srcpos - start position in the source data
dest - the destination
destpos - start position in the destination data
length - length of the data to be copied
Throws: ArrayIndexOutOfBoundsException
Copy would cause access of data outside array bounds

arraycopy

  public static void arraycopy(int src[],
                               int srcpos,
                               int dest[],
                               int destpos,
                               int length)
Copies an array of integers.
Parameters:
src - the source data
srcpos - start position in the source data
dest - the destination
destpos - start position in the destination data
length - length of the data to be copied
Throws: ArrayIndexOutOfBoundsException
Copy would cause access of data outside array bounds

arraycopy

  public static void arraycopy(long src[],
                               int srcpos,
                               long dest[],
                               int destpos,
                               int length)
Copies an array of longs.
Parameters:
src - the source data
srcpos - start position in the source data
dest - the destination
destpos - start position in the destination data
length - length of the data to be copied
Throws: ArrayIndexOutOfBoundsException
Copy would cause access of data outside array bounds

arraycopy

  public static void arraycopy(float src[],
                               int srcpos,
                               float dest[],
                               int destpos,
                               int length)
Copies an array of floats.
Parameters:
src - the source data
srcpos - start position in the source data
dest - the destination
destpos - start position in the destination data
length - length of the data to be copied
Throws: ArrayIndexOutOfBoundsException
Copy would cause access of data outside array bounds

arraycopy

  public static void arraycopy(double src[],
                               int srcpos,
                               double dest[],
                               int destpos,
                               int length)
Copies an array of doubles.
Parameters:
src - the source data
srcpos - start position in the source data
dest - the destination
destpos - start position in the destination data
length - length of the data to be copied
Throws: ArrayIndexOutOfBoundsException
Copy would cause access of data outside array bounds

arraycopy

  public static void arraycopy(Object src[],
                               int srcpos,
                               Object dest[],
                               int destpos,
                               int length)
Copies an array of objects.
Parameters:
src - the source data
srcpos - start position in the source data
dest - the destination
destpos - start position in the destination data
length - length of the data to be copied
Throws: ArrayIndexOutOfBoundsException
copy would cause access of data outside array bounds
Throws: IncompatibleTypeException
Source and destination array types do not match

exit

  public static void exit(int status)
Exits the interpreter with an exit code. This method does not return, use with caution.
Parameters:
status - exit status, 0 is success

execin

  public static InputStream execin(String command)
Executes a system command. Returns a FileInputStream connected to the standard output of the command. Fails if executed directly or indirectly by code loaded over the net.

execout

  public static OutputStream execout(String command)
Executes a system command. Returns a FileOutputStream connected to the standard input of the command. Fails if executed directly or indirectly by code loaded over the net.

exec

  public static void exec(String command)
Executes a system command. No redirection.

getenv

  public static String getenv(String var)
Gets an environment variable. An environment variable is a system dependent external variable that has a string value.
Parameters:
var - the name of an environment variable.
Returns:
the value of the variable, or null if the variable is is not defined

getCWD

  public static String getCWD()
Get the current working directory.
Returns:
the system dependent name of the current directory.

getOSName

  public static String getOSName()
Get the name of the operating system. In the rare event that you need to do something OS dependent, this is how you find out what you're running on.
Returns:
the system dependent name of current operating system.

traceInstructions

  public static void traceInstructions(int on)
Enables/Disables tracing of instructions.
Parameters:
on - start tracing if non-zero

traceMethodCalls

  public static void traceMethodCalls(int on)
Enables/Disables tracing of method calls.
Parameters:
on - start tracing if non-zero

profile

  public static void profile(int on)
Enables/Disables profiling of method calls.
Parameters:
on - start profiling if non-zero

dumpProfile

  public static void dumpProfile()
Dumps profiling data.

dumpMon

  public static void dumpMon(Object obj)
Dumps the state of all monitors.


All Packages    This Package    Previous    Next