home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / 1&1 / java.z / java_301 / java / lang / System.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-10-20  |  4.0 KB  |  125 lines

  1. package java.lang;
  2.  
  3. import java.io.BufferedInputStream;
  4. import java.io.BufferedOutputStream;
  5. import java.io.FileDescriptor;
  6. import java.io.FileInputStream;
  7. import java.io.FileOutputStream;
  8. import java.io.InputStream;
  9. import java.io.PrintStream;
  10. import java.util.Properties;
  11.  
  12. public final class System {
  13.    // $FF: renamed from: in java.io.InputStream
  14.    public static final InputStream field_0;
  15.    public static final PrintStream out;
  16.    public static final PrintStream err;
  17.    private static SecurityManager security;
  18.    private static Properties props;
  19.  
  20.    private System() {
  21.    }
  22.  
  23.    private static InputStream InputStreamInitializer(FileDescriptor fd) {
  24.       try {
  25.          return new BufferedInputStream(new FileInputStream(fd), 128);
  26.       } catch (Exception e) {
  27.          throw new Error("can't initialize System input stream: " + e);
  28.       }
  29.    }
  30.  
  31.    private static PrintStream OutputStreamInitializer(FileDescriptor fd) {
  32.       try {
  33.          return new PrintStream(new BufferedOutputStream(new FileOutputStream(fd), 128), true);
  34.       } catch (Exception e) {
  35.          throw new Error("can't initialize System output stream " + fd + ": " + e);
  36.       }
  37.    }
  38.  
  39.    private static native void setSystemIO(InputStream var0, PrintStream var1, PrintStream var2);
  40.  
  41.    public static void setSecurityManager(SecurityManager s) {
  42.       if (security != null) {
  43.          throw new SecurityException("SecurityManager already set");
  44.       } else {
  45.          security = s;
  46.          SecurityManager.setSecurityManager();
  47.       }
  48.    }
  49.  
  50.    public static SecurityManager getSecurityManager() {
  51.       return security;
  52.    }
  53.  
  54.    public static native long currentTimeMillis();
  55.  
  56.    public static native void arraycopy(Object var0, int var1, Object var2, int var3, int var4);
  57.  
  58.    private static native Properties initProperties(Properties var0);
  59.  
  60.    public static Properties getProperties() {
  61.       if (props == null) {
  62.          props = initProperties(new Properties());
  63.       }
  64.  
  65.       SecurityManager.checksPropertiesAccess(1);
  66.       return props;
  67.    }
  68.  
  69.    public static void setProperties(Properties props) {
  70.       SecurityManager.checksPropertiesAccess(1);
  71.       System.props = props;
  72.    }
  73.  
  74.    public static String getProperty(String key) {
  75.       SecurityManager.checksPropertyAccess(key, 1);
  76.       if (props == null) {
  77.          props = initProperties(new Properties());
  78.       }
  79.  
  80.       return props.getProperty(key);
  81.    }
  82.  
  83.    public static String getProperty(String key, String def) {
  84.       SecurityManager.checksPropertyAccess(key, 1);
  85.       if (props == null) {
  86.          props = initProperties(new Properties());
  87.       }
  88.  
  89.       return props.getProperty(key, def);
  90.    }
  91.  
  92.    public static String getenv(String name) {
  93.       throw new Error("getenv no longer supported, use properties and -D instead: " + name);
  94.    }
  95.  
  96.    public static void exit(int status) {
  97.       Runtime.getRuntime().exit(status);
  98.    }
  99.  
  100.    // $FF: renamed from: gc () void
  101.    public static void method_0() {
  102.       Runtime.getRuntime().gc();
  103.    }
  104.  
  105.    public static void runFinalization() {
  106.       Runtime.getRuntime().runFinalization();
  107.    }
  108.  
  109.    public static void load(String filename) {
  110.       SecurityManager.checksLink(filename, 1);
  111.       Runtime.getRuntime().load(filename);
  112.    }
  113.  
  114.    public static void loadLibrary(String libname) {
  115.       SecurityManager.checksLink(libname, 1);
  116.       Runtime.getRuntime().loadLibrary(libname);
  117.    }
  118.  
  119.    static {
  120.       field_0 = InputStreamInitializer(FileDescriptor.in);
  121.       out = OutputStreamInitializer(FileDescriptor.out);
  122.       err = OutputStreamInitializer(FileDescriptor.err);
  123.    }
  124. }
  125.