img
Method
Description
static Channel inheritedChannel( )
Returns the channel inherited by the Java Vir tual
throws IOException
Machine. Returns null if no channel is inherited.
static void load(String librar yFileName)
Loads the dynamic librar y whose file is specified by
librar yFileName, which must specify its complete path.
static void loadLibrar y(String librar yName)
Loads the dynamic librar y whose name is
associated with librar yName.
static String mapLibrar yName(String lib)
Returns a platform-specific name for the librar y
named lib.
static long nanoTime( )
Obtains the most precise timer in the system and
returns its value in terms of nanoseconds since
some arbitrar y star ting point. The accuracy of the
timer is unknowable.
static void runFinalization( )
Initiates calls to the finalize( ) methods of unused
but not yet recycled objects.
static void setErr(PrintStream eStream)
Sets the standard err stream to eStream.
static void setIn(InputStream iStream)
Sets the standard in stream to iStream.
static void setOut(PrintStream oStream)
Sets the standard out stream to oStream.
static void
Sets the current system proper ties as specified by
setProper ties(Proper ties sysProper ties) sysProper ties.
static String setProper ty(String which,
Assigns the value v to the proper ty named which.
String v)
static void setSecurityManager(
Sets the security manager to that specified by
SecurityManager secMan)
secMan.
TABLE 16-13
The Methods Defined by System (continued)
Using currentTimeMillis( ) to Time Program Execution
One use of the System class that you might find particularly interesting is to use the
currentTimeMillis( ) method to time how long various parts of your program take to execute.
The currentTimeMillis( ) method returns the current time in terms of milliseconds since
midnight, January 1, 1970. To time a section of your program, store this value just before
beginning the section in question. Immediately upon completion, call currentTimeMillis( )
again. The elapsed time will be the ending time minus the starting time. The following
program demonstrates this:
// Timing program execution.
class Elapsed {
public static void main(String args[]) {
long start, end;
System.out.println("Timing a for loop from 0 to 1,000,000");
// time a for loop from 0 to 1,000,000
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home