我有一段代码,我必须在其中读取文件以获取其可能的内容。
我遇到了同样的路径操作错误。
PFB 代码:
while ((ze = zis.getNextEntry()) != null) {
String fileName = ze.getName();
String esapiFileName = ESAPI.encoder().canonicalize(fileName);
boolean esapiValidFileName = ESAPI.validator().isValidFileName("upload", esapiFileName, false);
String _completefileNamePath = null;
if (esapiValidFileName) {
_completefileNamePath = _destination + esapiFileName;
// Below line having Path Manipulation error
FileOutputStream fos = new FileOutputStream(new File(_completefileNamePath).getCanonicalFile());
// Path Manipulation error ends
while ((size = zis.read(buffer, 0, buffer.length)) != -1) {
fos.write(buffer, 0, size);
}// while
fos.flush();
fos.close();
zis.closeEntry();
}
}