Class com.theorem.compression.cacm87

java.lang.Object
   |
   +----com.theorem.compression.cacm87

public class cacm87
extends Object
Author:
Michael Lecuyer - translator.
Arithmetic Compression Algorithm from Witten, I.H., Neal, R. and Cleary, J.G. (1987) ``Arithmetic coding for data compression,'' Comm ACM: 30(6): 520-540; June.

For further discussion, see also Witten, I.H., Neal, R. and Cleary, J.G. (1988) ``Compress and compact discussed further,'' Comm ACM: 31(9): 1140, 1145; September (reply to a letter to the editor). The code is also described in the book Bell, T.C., Cleary, J.G. and Witten, I.H. Text compression. Prentice Hall, Englewood Cliffs, NJ, 1990.

This algorithm was translated from the original C language code available at ftp://ftp.cpsc.ucalgary.ca/pub/projects/ar.cod

Most of the C code was left intact where possible, some minor optimizations were made, and wrapper methods added to enhance usefulness.


Method Index

 o byteArrayCompress(byte[], int, int)
Compress an array of bytes into another byte array.
 o byteArrayDecompress(byte[], int, int)
Decompress an array of bytes into another byte array.
 o byteFileCompress(String)
Compress a file into an array of bytes
 o byteFileDecompress(String)
Decompress the contents of a file into a byte array
 o fileCompress(String, String)
Compress a file into another file.
 o fileDecompress(String, String)
Decompress the contents of a file into another file.

Methods

 o byteArrayCompress
 public byte[] byteArrayCompress(byte inData[],
                                 int offset,
                                 int length)
Compress an array of bytes into another byte array.

Parameters:
inData - byte array of input
Returns:
byte[] compressed byte array
 o byteFileCompress
 public byte[] byteFileCompress(String fName)
Compress a file into an array of bytes

Parameters:
fName - file name of input
Returns:
byte[] compressed byte array, or null if something went wrong.
 o fileCompress
 public boolean fileCompress(String fIn,
                             String fOut)
Compress a file into another file.

Parameters:
fIn - file name of input
fOut - file name of output
Returns:
true[] if compression succeeded, false if something failed in the process.
 o byteArrayDecompress
 public byte[] byteArrayDecompress(byte inData[],
                                   int offset,
                                   int length)
Decompress an array of bytes into another byte array.

Parameters:
inData - byte array of compressed input
Returns:
byte[] decompressed byte array
 o byteFileDecompress
 public byte[] byteFileDecompress(String fName)
Decompress the contents of a file into a byte array

Parameters:
name - of file containing compressed data
Returns:
byte array of decompressed input
 o fileDecompress
 public boolean fileDecompress(String fIn,
                               String fOut)
Decompress the contents of a file into another file.

Parameters:
fIn - name of file containing compressed data
fOut - name of file to send decompressed data
Returns:
true if decompression worked., false if anything failed.