/* * @(#)System.java 1.55 95/11/13 Arthur van Hoff * * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved. * * Permission to use, copy, modify, and distribute this software * and its documentation for NON-COMMERCIAL purposes and without * fee is hereby granted provided that this copyright notice * appears in all copies. Please refer to the file "copyright.html" * for further important copyright and licensing information. * * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package java.lang; import java.io.*; import java.util.Properties; import java.util.StringTokenizer; /** * This Class provides a system-independent interface to system * functionality. One of the more useful things provided by this Class * are the standard input and output streams. The standard input streams are * used for reading character data. The standard output streams are used for * printing. For example: * * System.out.println("Hello World!"); * * This Class cannot be instantiated or subclassed because all of the methods * and variables are static. * @version 1.55, 13 Nov 1995 * @author Arthur van Hoff */ public final class System { /** Don't let anyone instantiate this class */ private System() { } /** * Standard input stream. This stream is used for reading in character * data. */ public static InputStream in; /** * Standard output stream. This stream is used for printing messages. */ public static PrintStream out; /** * Standard error stream. This stream can be used to print error messages. * Many applications read in data from an InputStream and output messages via * the PrintStream out statement. Often applications rely on command line * redirection to specify source and destination files. A problem with redirecting * standard output is the incapability of writing messages to the screen if the * output has been redirected to a file. This problem can be overcome by sending * some output to PrintStream out and other output to PrintStream err. The * difference between PrintStream err and PrintStream out is that PrintStream * err is often used for displaying error messages but may be used for any purpose. */ public static PrintStream err; static { try { in = new BufferedInputStream(new FileInputStream(FileDescriptor.in), 128); out = new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.out), 128), true); err = new PrintStream(new BufferedOutputStream(new FileOutputStream(FileDescriptor.err), 128), true); } catch (Exception e) { throw new Error("can't initialize stdio"); } } /* The security manager for the system. */ private static SecurityManager security; /** * Sets the System security. This value can only be set once. * @param s the security manager * @exception SecurityException If the SecurityManager has already been set. */ public static void setSecurityManager(SecurityManager s) { if (security != null) { throw new SecurityException("SecurityManager already set"); } security = s; } /** * Gets the system security interface. */ public static SecurityManager getSecurityManager() { return security; } /** * Returns the current time in milliseconds GMT since the epoch (00:00:00 * UTC, January 1, 1970). It is a signed 64 bit integer, and so it will * not overflow until the year 292280995. * @see java.util.Date */ public static native long currentTimeMillis(); /** * Copies an array from the source array, beginning at the * specified position, to the specified position of the destination array. * This method does not allocate memory for the destination array. The * memory must already be allocated. * @param src the source data * @param srcpos start position in the source data * @param dest the destination * @param destpos start position in the destination data * @param length the number of array elements to be copied * @exception ArrayIndexOutOfBoundsException If copy would cause * access of data outside array bounds. * @exception ArrayStoreException If an element in the src array could * could not be stored into the destination array due * to a type mismatch */ public static native void arraycopy(Object src, int src_position, Object dst, int dst_position, int length); /** * System properties. The following properties are guaranteed to be defined: *