郵便番号はかなり簡単ですが、ZipInputStreamをInputstreamとして返す際に問題が発生しました。何らかの理由で、zip内に含まれているファイルの一部で文字が削除されていました。以下は私の解決策であり、これまでのところ機能しています。
private Map<String, InputStream> getFilesFromZip(final DataHandler dhZ,
String operation) throws ServiceFault
{
Map<String, InputStream> fileEntries = new HashMap<String, InputStream>();
try
{
DataSource dsZ = dhZ.getDataSource();
ZipInputStream zipIsZ = new ZipInputStream(dhZ.getDataSource()
.getInputStream());
try
{
ZipEntry entry;
while ((entry = zipIsZ.getNextEntry()) != null)
{
if (!entry.isDirectory())
{
Path p = Paths.get(entry.toString());
fileEntries.put(p.getFileName().toString(),
convertZipInputStreamToInputStream(zipIsZ));
}
}
}
finally
{
zipIsZ.close();
}
}
catch (final Exception e)
{
faultLocal(LOGGER, e, operation);
}
return fileEntries;
}
private InputStream convertZipInputStreamToInputStream(
final ZipInputStream in) throws IOException
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copy(in, out);
InputStream is = new ByteArrayInputStream(out.toByteArray());
return is;
}