May 31, 2017
JAVA:获得平台相关的行分隔符、路径分隔符,兼容各平台
【问题】
不同系统平台下的行分隔符、路径分隔符等常常不同。如
行分隔符在windows 下是 \r\n,在Linux下面是 \n, 在Mac下是 \r
路径分隔符在windows下是 \ ,在LInux下是 /
——来自网络资料
如何在Java程序获取当前平台的分隔符,以及其他系统相关的状态呢?
import java.util.Properties;
public class SeparatorUtils {
/* system properties to get separators */
static final Properties PROPERTIES = new Properties(System.getProperties());
/**
* get… Read More