JDK 源码:System

System 类提供了访问系统相关信息和操作的方法,例如标准输入、输出、错误流、系统属性等。以下是 JDK 8 中 System 类的部分源代码:

public final class System {
    private System() {}

    public static final InputStream in = null;
    public static final PrintStream out = null;
    public static final PrintStream err = null;

    public static void setIn(InputStream inStream) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static void setOut(PrintStream outStream) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static void setErr(PrintStream errStream) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static native long currentTimeMillis();

    public static native long nanoTime();

    public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length);

    public static native int identityHashCode(Object x);

    public static Properties getProperties() {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static String getProperty(String key) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static String getProperty(String key, String def) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static String setProperty(String key, String value) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static String clearProperty(String key) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static String getenv(String name) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static Map<String, String> getenv() {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static void exit(int status) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static void gc() {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static void runFinalization() {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static void load(String filename) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static void loadLibrary(String libname) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static String mapLibraryName(String libname) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static void arraycopy(Object src,  int  srcPos,
                                  Object dest, int destPos,
                                  int length)
    {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static int identityHashCode(Object x) {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static Console console() {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static Channel inheritedChannel() throws IOException {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static Path getTemporaryDirectory() {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static SecurityManager getSecurityManager() {
        throw new UnsupportedOperationException("Method not supported");
    }

    public static void setSecurityManager(SecurityManager s) {
        throw new UnsupportedOperationException("Method not supported");
    }
}

System 类包含了一些静态方法,可以用来获取系统属性、当前时间、标准输入输出流、执行垃圾回收等。不过,在实际应用中,通常会使用更高级的工具类来代替 System 类的部分功能,比如使用 java.util.logging.Logger 代替 System.out.println 来进行日志输出。

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值