Class ZipArchiveInputStream
java.lang.Object
xyz.apollosoftware.bibliothiki.compression.ArchiveInputStream
xyz.apollosoftware.bibliothiki.compression.formats.zip.ZipArchiveInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
An adapter for the built-in
java.util.zip capability.-
Field Summary
Fields inherited from class xyz.apollosoftware.bibliothiki.compression.ArchiveInputStream
stream -
Constructor Summary
ConstructorsConstructorDescriptionZipArchiveInputStream(@NonNull InputStream stream) Construct aZipArchiveInputStreamthat encapsulates the givenInputStream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidClose the current entry.@Nullable ArchiveEntryGet the next entry in the archive.static booleanisZipStream(@NonNull InputStream stream) Peek the first four bytes of the stream to see if they match the ZIP magic number.voidwriteCurrentEntryTo(@NonNull OutputStream stream) Write the current archive entry to the givenOutputStream.Methods inherited from class xyz.apollosoftware.bibliothiki.compression.ArchiveInputStream
detect
-
Constructor Details
-
ZipArchiveInputStream
Construct aZipArchiveInputStreamthat encapsulates the givenInputStream.- Parameters:
stream- The input stream that will provide ZIP data.
-
-
Method Details
-
isZipStream
Peek the first four bytes of the stream to see if they match the ZIP magic number.- Parameters:
stream- The stream to check.- Returns:
- True, if the stream is a ZIP stream, otherwise false.
-
getNextEntry
Description copied from class:ArchiveInputStreamGet the next entry in the archive.If there are no (more) entries in the archive, this method returns null, instead.
- Specified by:
getNextEntryin classArchiveInputStream- Returns:
- The
ArchiveEntry, if there is one. - See Also:
-
writeCurrentEntryTo
Description copied from class:ArchiveInputStreamWrite the current archive entry to the givenOutputStream.The
ArchiveInputStream.getNextEntry()must have been called prior, or this method will throw aCompressionException.A common pattern for writing to files, therefore, would be to invoke
ArchiveInputStream.getNextEntry()and then write the file data with this method.Some implementations may return a
CompressionExceptionfor format or decompression failures. Implementations that do this will still returnIOExceptionwhen an exception is raised writing to the given output stream. In cases where it is not possible to disambiguate, anIOExceptionis always thrown instead.- Specified by:
writeCurrentEntryToin classArchiveInputStream- Parameters:
stream- The stream to write the file data to.- See Also:
-
closeCurrentEntry
public void closeCurrentEntry()Description copied from class:ArchiveInputStreamClose the current entry.This may be a no-op for some implementations.
- Specified by:
closeCurrentEntryin classArchiveInputStream
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classArchiveInputStream
-