LZH De/Compressor for Java

abooysen2
abooysen2 used Ask the Experts™
on
Hi

I need to decompress and compress a byte array in java using the LZH compression algorithm. The problem is that i can't seem to find the specification of the algorithm anywhere.
Does anyone have the specification or a program to do this.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
DeflaterInputStream will do that for you
Top Expert 2016

Commented:
Java Developer
Top Expert 2010
Commented:
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Author

Commented:
Hi

http://homepage1.nifty.com/dangan/en/Content/Program/Java/jLHA/jLHA.html

Have downloaded the jLHA.jar but have no idea how to use it and there is no documentation.

I need to decompress a byte array and not a .lzh file.

Thanks
Top Expert 2016

Commented:
What's the source of the byte array?
Top Expert 2016

Commented:
(If you can post a binary file containing it, i'll try it)

Author

Commented:
Hi

From a TCP  connection

Thank

Author

Commented:
Hi CEHJ:

Do you want the dompressed data or the jar file

Thanks
Top Expert 2016

Commented:
Compressed data pleased (assuming you want it decompressed)

Author

Commented:
Hi

Please find the compressed data attached after decompression i should have 130 bytes

Thanks
sub-message-in1.txt
Top Expert 2016

Commented:
I'm not convinced that's valid. LZH seems to have 'lh0' in its magic number

Author

Commented:
Hi

What does magic number mean?
Top Expert 2016

Commented:
A stream/file header that identifies it as LZH

Author

Commented:
Hi

Do have some link to the LZH specification?

Author

Commented:
Hi

Do you perhaps know how will i decompress and compress a byte array in java using the LZH algorithm.

Thanks
Anthonio
Top Expert 2016

Commented:
I'm afraid not

Author

Commented:

So is there is no solution to this?
Top Expert 2016

Commented:
Are you forced to adopt that scheme?

Author

Commented:
yes
Mick BarryJava Developer
Top Expert 2010

Commented:
> Do you perhaps know how will i decompress and compress a byte array in java using the LZH algorithm.

any of the implementations I posted above should handle it

Author

Commented:
Hi

http://homepage1.nifty.com/dangan/en/Content/Program/Java/jLHA/jLHA.html

Have downloaded the jLHA.jar but have no idea how to use it.

Thanks
Mick BarryJava Developer
Top Expert 2010

Commented:
docs are in japanese, not my best language :)
Mick BarryJava Developer
Top Expert 2010

Commented:
It'll still work :)  Works the same way the standard Zip classes work

Author

Commented:
Hi

Could you please show me how to use http://homepage1.nifty.com/dangan/en/Content/Program/Java/jLHA/jLHA.html

to becompress and compress a byte array

Thanks
Mick BarryJava Developer
Top Expert 2010

Commented:
same as you do for zipping

eg. something like this

        byte[] input = ......
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        LhaOutputStream zos = new LhaOutputStream(baos);
        LhaEntry entry = new LhaEntry("name");
        entry.setSize(input.length);
        zos.putNextEntry(entry);
        zos.write(input);
        zos.closeEntry();
        zos.close();
        byte[] output = baos.toByteArray();
Mick BarryJava Developer
Top Expert 2010

Commented:
I posted a valid answer to the question
Mick BarryJava Developer
Top Expert 2010

Commented:
I posted libraries for handling LZH at 33122213
And how to use them at 33141742

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial