比如说要在temp目录下建立一个test.txt文件,在Windows下应该这么写:
File file1 = new File ("C:\tmp\test.txt");
在Linux下则是这样的:
File file2 = new File ("/tmp/test.txt");
如果要考虑跨平台,则最好是这么写:
File myFile = new File("C:" + File.separator + "tmp" + File.separator, "test.txt");
String zip = savePath + File.separator + Common.QRCODE + File.separator + subpath +File.separator + batchCode + Common.ZIP;
windows linux 都写成 /temp 这样的也是可以的 谢谢 yanek 的告知