Click here to Skip to main content
15,917,731 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi
i read a file and convert it to string, and then after some en-coding with huffman, i write that string, to another file(compressed file)!
now when i decompress the file i can reach to first string
but when write it to a file its not the first file :|
what should i do?

but i should say that it works for text file correctly but
not for pictures !:|

example :
input file :
input = new FileInputStream( "f:/testpic.bmp" );

out put file:
BitOutputStream fop2 = new BitOutputStream("f:/is.oli");


when i read the output file and reach the first string, then write it to new file
its not the first :|

please help
thanks!
Posted

1 solution

Hi again me
I mentioned before some days, while coding Huffman forget thinking in string, think in stream of bytes.

Your picture will have probably a lot of zero's in it. If you handle this as string, then a Zero means “end of string”.

It means: Your program works fine for string...so you have to replace string by array (better stream) of bytes, byte[] :(

Regards
 
Share this answer
 
v4
Comments
DominoBoy 4-Jan-12 14:39pm    
its hard for me that working on java for three weeks
thx man :)
as always good answer tq!
[no name] 4-Jan-12 14:41pm    
It's cool that you don't give up and try to find and solve the problems/mistakes! Learning programming is a hard job :) three weeks are nothing. Regards

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900