判断当前java程序是运行在windows平台还是运行在linux平台的方法:
1.System.out.println(System.getProperty("file.separator"));
如果这个结果是"\"那么运行的系统就是windows平台,如果是"/"则是linux平台。
2
写道
if (System.getProperty("os.name").equals("Linux")) {
// linux
} else if (System.getProperty("os.name").equals("Windows XP")) {
//windows
}
1.System.out.println(System.getProperty("file.separator"));
如果这个结果是"\"那么运行的系统就是windows平台,如果是"/"则是linux平台。
2
写道
if (System.getProperty("os.name").equals("Linux")) {
// linux
} else if (System.getProperty("os.name").equals("Windows XP")) {
//windows
}