1、
From the JVM™ Tool Interface documentation…
Since the command-line cannot always be accessed or modified, for example in embedded VMs or simply VMs launched deep within scripts, a
JAVA_TOOL_OPTIONS
variable is provided so that agents may be launched in these cases.
By setting the (Windows) environment variable JAVA_TOOL_OPTIONS
to -Dfile.encoding=UTF-8
, the (Java) System
property will be set automatically every time a JVM is started. You will know that the parameter has been picked up because the following message will be posted to System.err
:
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
2020-09-27追加: JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
-Duser.timezone=GMT+8
2、
使用| 作为分割符需要转义
String str = "1|2|3|4|5|6|7|8|9|0";
String[] result = str.split("\\|");
3、获取当前项目目录
System.getProperty("user.dir");