System.out.println("extract \"" + fileName + "\" from \"" + rarName + "\"");
InputStream res = null;
File file = new File(rarName);
if (file.exists()) {
ZipFile zipFile = new ZipFile(file.getAbsolutePath());
for (Enumeration zippedFiles = zipFile.entries(); zippedFiles.hasMoreElements(); ) {
//Retrieve entry of existing files
ZipEntry currEntry = (ZipEntry) zippedFiles.nextElement();
if (debug)
System.out.println("RAConfig.extractFromRAR : currEntry = " + currEntry);
if (currEntry.getName().equalsIgnoreCase(fileName)
|| currEntry.getName().equalsIgnoreCase("META-INF/"+fileName)) {
// the fileName is found.
res = zipFile.getInputStream(currEntry);
break;
} else if (currEntry.getName().endsWith(".jar")) {
// search fileName in jar file.
InputStream reader = zipFile.getInputStream(currEntry);
res = extractFromJAR(fileName,reader);
if (res == null) continue;
// the fileName found in jar file.
reader.close();
break;
}
}
// extract the fileName from InputStream
// in the tmp directory.
if (res != null)
createFile(fileName,res);
zipFile.close();
}
}