CPS 100, Fall 2006, Huff FAQ

    Items below are FAQ answers as the assignment goes out

  1. Deleting a file from a Java program

    To unlink a file in java, create a File object with the right name, path, then call the delete method on the object.

  2. Writing characters when unhuffing

    To write characters/8-bit chunks to an uncompressed file when unhuffing, use a BitOutputStream object and the write method.

    bitout.write(BITS_PER_WORD, value); where value is an int/8-bit chunk stored in a leaf of a Huffman tree, for example -- the leaf your code finds during uncompression.

  3. Are files the same?

    There's a program Diff.java that will report of two files are byte-wise identical.

  4. pseudo-eof

    You must create a node, with count/weight 1, that contains PSEUDO_EOF (see IHuffConstants.java) as the info field of the node, and add this node to the collection of nodes used to make the Huffman tree. You must create this node explicitly, it's not created automatically from your counts.

    Once created, it will become part of the tree and thus have a zero/one encoding derived from the root-to-leaf path.

    You must write this encoding after compressing all the "real" characters (when you re-read the file being compressed). You must write the encoding explicitly.

    Your unhuff program will know what the encoding of PSEUDO_EOF is -- see the assignment write-up for how to use the pseudo-eof value when uncompressing.


Owen Astrachan
Last modified: Mon Oct 30 08:53:09 EST 2006