before this question gets closed for repetition - yes, I have read the other posts and their content was different, also the answers did not help in my case.
I have a zip file in my JEE-Project called Export.zip
. It is located in the resources
folder.
I am trying to unzip it and store it in a folder, which will be created by the Unzipper.
The Unzipper looks like this:
public String unzip(String zipFilePath, String destDirectory) throws IOException {
String path = "";
File destDir = new File(destDirectory);
if (!destDir.exists()) {
destDir.mkdirs();
}
ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));
ZipEntry entry = zipIn.getNextEntry();
// iterates over entries in the zip file
while (entry != null) {
String filePath = destDirectory + File.separator + entry.getName();
if (!entry.isDirectory()) {
// if the entry is a file, extracts it
extractFile(zipIn, filePath);
path = filePath;
} else {
// if the entry is a directory, make the directory
File dir = new File(filePath);
dir.mkdir();
}
zipIn.closeEntry();
entry = zipIn.getNextEntry();
}
zipIn.close();
return path;
}
That is the method causing problems:
public String getPath() throws IOException {
String destDirectory = "unzip/";
String pathOuterZip =
"../standalone/deployments/phonenumbersmanagement-0.0.1-SNAPSHOT.war/WEB-INF/classes/files/";
this.logger.info("pathOuterZip: " + pathOuterZip);
//THE LINE BELOW THROWS THE EXCEPTION!
String filePathInnerZip = unzipper.unzip(pathOuterZip + "Export.zip",
pathOuterZip + destDirectory);
//THIS WONT BE EXECUTED CAUSE OF THE EXCEPTION
this.logger.info("filePathInnerZip: " + filePathInnerZip);
String pathExportAll = unzipper.unzip(filePathInnerZip, pathOuterZip
+ destDirectory);
this.logger.info("pathExportAll: " + pathExportAll);
return pathExportAll;
}
That is the error I am getting:
java.io.FileNotFoundException: ..\standalone\deployments\phonenumbersmanagement-0.0.1-SNAPSHOT.war\WEB-INF\classes\files\unzip\${_DUMMY_DIR}\${_NO_RESTORE}dummy.txt (Das System kann den angegebenen Pfad nicht finden/System cannot find Path)
The problem is, I do not know why it points to the text file shown in the error.
To understand how the Export.zip looks like, this is the result when unzipping it:
${_DUMMY_DIR} (folder)
${exportWorkingDir} (folder)
The first folder contains the ${_NO_RESTORE}dummy.txt
, which is mentioned in the stacktrace.
Can anybody help me to understand what is going on? Any help is appreciated. Thank you.