linux和windows路径处理

//本地路径

String relativeSyncFilePath = "xxxxx";

//获取操作系统

Properties prop = System.getProperties();

String os = prop.getProperty("os.name");

//判断是不是windiws操作系统

if(os.startsWith("win") || os.startsWith("Win")){ 
//windows操作系统,斜杠做转换
relativeSyncFilePath = relativeSyncFilePath.replaceAll("/", "\\\\");
}

你可能感兴趣的:(java)