The Java System class common method

1. Definitions

  • public final class System is final modification, it said it could not be inherited
  • private System () method of privatization, it said it could not create an instance
  • All methods are all static modified

2, a common method

System.getProperty(String key)

Where key parameters are the following:

  • user.dir
    current working directory project or module
  • user.home
    the current user's home directory, Windows forms: C: \ Users \ Rongdi
  • user.name
    current user name
  • line.separator
    line break points, that is the end of the line break our file
  • file.separator
    path separator, the systems are not the same, win \
  • java.version
    system version

System.exit(int status)

提前退出,后面的代码不再执行,我们可以通过设置不同的状态值来标明程序是否正常退出。

System.currentTimeMillis()

返回操作系统当前的毫秒时间戳
这个在爬虫中会经常看到,作为js加密的一种手段
长度为13位,所以在爬虫中看到了一个13位的数字,第一时间就应该想到是时间戳

System.arraycopy(src, start, dest, start, end)

实现数组的拷贝,其中的start和end均为索引,且是左闭又开的

3, FIG mind summarized as follows

Here Insert Picture Description

Published 141 original articles · won praise 131 · views 210 000 +

Guess you like

Origin blog.csdn.net/qq_41621362/article/details/105315651