这是我的部分代码
OutputStream os;
if (isWin){
os = new FileOutputStream(folder + "\" + destinationFile);
}
else{
os = new FileOutputStream(folder + "/" + destinationFile);
}
我在反斜杠行收到“字符串文字未被双引号错误正确关闭”。如果我删除反斜杠或将其更改为正斜杠,错误将消失。
我该如何解决这个问题?谢谢。
最佳答案
分隔符最好使用 File
api,这样你就不必检查它是什么操作系统了:
os = new FileOutputStream(folder + File.separatorChar + destinationFile);
关于java - String literal is not properly closed 错误的反斜杠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31852318/