Discussion Board
There are no previous messagesGo to the following message
Current Forum: Homework 4 - Huffman Trees (Part 1)
Date: Fri Oct 12 2001 3:55 pm
Author: Sakr, Hisham A. <hsakr@andrew.cmu.edu>
Subject: Cant get readHeader to work

I am able to successfully write a header to the file using the supplied writeHeader function. I know this because opening the file up in a bin/hex editor shows
.0 ☺0 ☻0 ♥0 ♦0 ♣
0 ♠0 .0 .0 .0 .0
♂0 ♀0 .0 ♫0 ☼0
►0 ◄0 ↕0 ‼0 ¶0 §
0
etc. in the form of [character][frequency][space] repeated. All 256 ascii characters are in the file, and the frequencies next to them are exactly as they are in the input files.

My problem is, when I want to decompress and I call readHeader, it only reads in the info for the first 32 characters (not the full 256), then stops.

Here is the code I wrote to display what readHeader is giving me:
(please excuse bad formatting)

Vector HuffmanCharFreqsVector = new Vector();
        HuffmanCharFreqsVector = readHeader((FileBitReader)in);
        System.out.println("Here is the header that got read in");
        for(int i=0; i< HuffmanCharFreqsVector.size(); i++)
        {
                System.out.println( ((HuffmanCharFreq)HuffmanCharFreqsVector.elementAt(i)).getCharacter().toString() + ((HuffmanCharFreq)HuffmanCharFreqsVector.elementAt(i)).getFrequency() );
        }

and here is the output:

Here is the header that got read in
0
☺0
☻0
♥0
♦0
♣0
♠0
0
0
0

0
♂0
♀0
0
♫0
☼0
►0
◄0
↕0
‼0
¶0
§0
▬0
↨0
↑0
↓0
→0
←0
∟0
↔0
▲0
▼0

it stops there, and I don't know why! I really dont want to have to rewrite the header read/write code if possible.

Thanks in advance for anyone who has any suggestions.
Post response

There are no previous messagesGo to the following message
Current Thread Detail:
Cant get readHeader to work      Sakr, Hisham A.      Fri Oct 12 2001 3:55 pm       
Nevermind!      Sakr, Hisham A.      Fri Oct 12 2001 4:07 pm       

Back to previous screen