本文共 235 字,大约阅读时间需要 1 分钟。
在Windows中,斜杠用的是正斜杠 \,如C:\Program Files\image
在Linux中,斜杠用的是反斜杠 /,如usr/local/nginx为了能更好的适配各种系统,在路径拼接的时候可以用File.separator来进行拼接,通过代码来获取系统的分隔符。
import java.io.File;
使用方法如下:Spring path = 'image' + File.separator + 'small.jpg'
转载地址:http://usxvi.baihongyu.com/