object ZipReader extends Loggable
Utility for reading the contents of a Zip file.
This object provides two methods for reading, each of which manage the opening and closing of filesystem resources so that client code doesn't have to. It also provides a means to simply check if a file is a Zip file or not.
Each of the utility methods can operate on either a String (file path) or File (java.io.File).
This is accomplished via the ZipOpenable
typeclass defined in this object
- Alphabetic
- By Inheritance
- ZipReader
- Loggable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- class Entry extends AnyRef
- implicit class RichZipFile extends AnyRef
- trait ZipOpenable[T] extends AnyRef
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
val
entryNameCharset: Charset
The character set used to decode zip entry names.
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isZip[T](resource: T)(implicit arg0: ZipOpenable[T]): Boolean
-
implicit
val
logger: Logger
- Attributes
- protected
- Definition Classes
- Loggable
- Annotations
- @transient()
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
readAsZipFile[T, Result](resource: T)(readZip: (ZipFile) ⇒ Result)(implicit arg0: ZipOpenable[T]): Result
Read the given
resource
as a Zip file, passing the actualZipFile
instance to thereadZip
function before automatically closing it. -
def
readAsZipStream(rawStream: InputStream): Iterator[(ZipEntry, InputStream)]
Read the given
rawStream
as a ZipInputStream, exposing an Iterator over the entries, each paired with their respective contents.Read the given
rawStream
as a ZipInputStream, exposing an Iterator over the entries, each paired with their respective contents. This method DOES NOT automatically close the underlying stream. -
def
readNestedZip(zipContent: InputStream, depthLimit: Option[Int] = None, zipExtensions: Set[String] = Set("zip", "jar", "war", "ear"), pathFilter: (String) ⇒ Boolean = _ => true, shouldGoDeeper: (List[String]) ⇒ Boolean = _ => true): Iterator[(List[String], InputStream)]
Reads a zip file that may contain other zip files nested within itself.
Reads a zip file that may contain other zip files nested within itself. The
zipContent
is assumed to be a valid zip file; if it isn't, this method will fail.- zipContent
An InputStream that represents the content of the zip file being read
- depthLimit
An optional limit on the number of nesting levels to read. A value of 0 or less implies that the stream should not be read, as the assumption is that
zipContent
is a zip file, so anything inside of it would have a depth of 1. Default is no limit.- zipExtensions
A set of filename extensions (no dot) that signify a nested zip. Default values are "zip", "jar", "war", and "ear".
- pathFilter
A function that decides whether or not to consider a given entry by its path. Defaults to a function that returns
true
for all inputs.- shouldGoDeeper
A function that decides whether or not explore the children of a (nested) zip. Its only parameter is a list of paths (explained in the
return
section) to the node in consideration. IfshouldGoDeeper(paths)
returnstrue
, the reader will continue into that entry's content, yielding their individual paths and contents to the returned iterator. Otherwise, the returned iterator will simply yield the entry itself and not "go deeper".- returns
An iterator over each possibly-nested entry in the zip file represented by
zipContent
, producing a tuple for each entry. The first member of the tuple is a list of paths, representing the current location within the nested zips. For example:"WEB-INF/lib/some-library.jar" :: "com/foo/bar/Stuff.class" :: Nil
would represent the "Stuff.class" file, compressed within "some-library.jar", which was encountered in thezipContent
. The second member of the tuple is an InputStream containing the contents of that entry.
-
def
readZip[T, Result](resource: T)(readEntries: (List[Entry]) ⇒ Result)(implicit arg0: ZipOpenable[T]): Result
Read the given
resource
as a Zip file, using the givenreadEntries
function to generate some Result value.Read the given
resource
as a Zip file, using the givenreadEntries
function to generate some Result value. The entries will be readable *only* during this function; any attempts to do so after this function call will result in IOExceptions because the underlying zip resource will be closed. - def readZipIteratively[T, Result](resource: T)(readEntries: (Iterator[Entry]) ⇒ Result)(implicit arg0: ZipOpenable[T]): Result
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- implicit object fileZipOpenable extends ZipOpenable[File]
- implicit object pathZipOpenable extends ZipOpenable[String]
Deprecated Value Members
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] ) @Deprecated
- Deprecated