Search this site

 Javamex Home  Arcmexer home  Reading encrypted archives  Password recovery

Arcmexer: library for reading archive files from Java

The Arcmexer Java library available here allows you to read several archive types in addition to the standard non-encrypted ZIP files that can be read with the standard JDK. The library is intended to be especially useful in data recovery and data conversion applications. It requires Java 5 or later.

Arcmexer currently allows you to read the following archive types:

Archive typeTypical filename extensionArchiveType constant
ZIP (Defalte compression, 128-bit AES encryption and traditional PKZIP encryption currently supported).zipArchiveType.ZIP
Gzipped tar.tar.gz

The librbary generally provides a unified interface for reading archives, whatever the type.

How to read from an archive

Download the Arcmexer jar and make sure that it is included in your project. All of the Arcmexer classes reside in the package com.javamex.arcmexer.

Reading files from an archive, whether it's a ZIP, tar etc, centres around two important classes: ArchiveReader and ArchiveEntry. The typical procedure is as follows:

  • you call ArchiveReader.getReader() around the archive file or stream that you want to read, to give you an ArchiveReader instance;
  • you successively call nextEntry() on that reader: each call returns the next ArchiveEntry object representing the metadata of the next item in the archive;
  • you can query the metadata with calls such as getFilename(), getCompressedLength(), getUncompressedLength();
  • to pull the data out of the archived file in question, call getInputStream() on the ArchiveEntry object.

In code, this would typically look as follows (omitting exceptions for clarity):

import com.javamex.arcmexer.*;

ArchiveReader r = ArchiveReader.getReader(f);
try {
  ArchiveEntry entry;
  while ((entry = r.nextEntry()) != null) {
    String filename = entry.getFilename();
    InputStream in = entry.getInputStream();
    // ... read from in
} finally {

Next topics

Copyright © Javamex UK 2009. All rights reserved. Please note that the software provided on this site is provided "as is".
No guarantee is made that it will be suitable for a particular purpose. In downloading the software, you agree to use it at your own risk. You also agree not to use it for any illegal purpose.