文件分隔符在不同的系统上是不一样的,windows系统上的文件分隔符是”\“,但是在Linux系统上就是”/“
在开发中需要注意这一点将分隔符换为File.separator
File.separator // 可根据系统的默认分隔符来进行变换
源码解释
/**
* The system-dependent default name-separator character. This field is
* initialized to contain the first character of the value of the system
* property <code>file.separator</code>. On UNIX systems the value of this
* field is <code>'/'</code>; on Microsoft Windows systems it is <code>'\\'</code>.
*
* @see java.lang.System#getProperty(java.lang.String)
*/
public static final char separatorChar = fs.getSeparator();
标签:java,路径,character,system,field,separator,分隔符,小坑
From: https://blog.csdn.net/qq_62669235/article/details/140403925