私は次のようにZipInputStreamを使用しています(コード):
public InputStream getArtifactInputStream(InputStream contentInputStream)
throws ArtifactProviderException
{
ZipInputStream zipInputStream = new ZipInputStream(contentInputStream);
InputStream artifactContent=null;
Properties externalizedProperties = null;
ZipEntry ze=null;
try {
ze = zipInputStream.getNextEntry();
} catch (IOException e) {
throw new ArtifactProviderException(e);
}
boolean propertiesFound = false;
try {
while (ze != null) {
String name = ze.getName();
if(name.endsWith(PROP_EXTENSION) && !ze.isDirectory())
{
externalizedProperties = new java.util.Properties();
externalizedProperties.load(zipInputStream);
propertiesFound = true;
}
else if(name.endsWith(ARTIFACT_EXTENSION) && !ze.isDirectory())
{
artifactContent = zipInputStream;
artifactName = name.substring(name.lastIndexOf("/")+1, name.indexOf(ARTIFACT_EXTENSION));
break;
}
ze=zipInputStream.getNextEntry();
}
} catch (IOException e) {
throw new ArtifactProviderException(e);
}
return artifactContent;
}
問題は、zipEntryでループしているときにPROP_EXTENSIONファイルが最初に表示されるのかARTIFACT_EXTENSIONが表示されるのかわからないため、これらのケースのいずれでも「break」を使用できないことです。breakwhileループを使用しないと、ループが完了します。最後に、artifactContentは「null」zipEntryを含むzipInputStreamを指します。
この問題を解決するにはどうすればよいですか、ここに代替手段はありますか?
'contentInputStream'は、基本的にjarまたはzipです。
問題を説明できるといいのですが、詳細が必要な場合は元に戻してください。
よろしくお願いします、Piyush