我们通过xp:fileUpload控件上传文件时注意到了不需要的行为。有时用户从其他用户上传文件。
文件名称相同但内容不同。
我用的是:
File correctedFile = new File(tempFile.getParentFile() + File.separator + tempClientFile);
从上传的文件在Notes文档中创建文件。
我在其他人的其他代码中注意到使用了以下内容:
File correctedFile = new File( serverFile.getParentFile().getAbsolutePath() + File.separator + fileName );
缺少绝对路径可能是文件切换的原因吗?
当然,我们从未在测试环境中的测试中发现过这种情况。
.getAbsolutePath()
返回完整路径,而在您的情况下隐式使用的.toString()
只返回抽象路径。
这是一个description of the difference。
我在我的Domino后端代码中使用.getAbsolutePath()
,从未遇到过您描述的问题。