Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI

I could able to Zip a file in java.But am not able reduce the size while compressing.

Please note:File could be any thing .exe or .txt etc.

Kindly help me for do this.kindly let me know any more information need to proceed this.



Thanks
Raj
Posted
Comments
phil.o 4-Mar-14 4:19am    
Please show the code you have so far.
Rajeshram009 4-Mar-14 4:47am    
The code is their in the below web path.
http://www.mkyong.com/java/how-to-compress-files-in-zip-format/

Thanks a lot..

 
Share this answer
 
Comments
Rajeshram009 4-Mar-14 4:50am    
Thanks Richard,

am looking to the same url what you shared.Am working on it.Its getting some error.i will be ping you if i need any support from you.
The first thing to note is the Zipping files will not necessarily reduce the size: some file formats are already highly compressed, and putting them into a ZIP archive can make them take more space instead of less - this is very true for video files and such like.

There is a workign example of how to do it here: http://www.mkyong.com/java/how-to-compress-files-in-zip-format/[^] - compare that code with your own, and see if there are any major differences.
 
Share this answer
 
Comments
Rajeshram009 4-Mar-14 4:46am    
Thanks.

Attached site is the same website that i followed earlier.The program under the margin "Advance ZIP example – Recursively" is working only.But this is not reducing the size.that means the output size is as same as input one.kindly help me for this.

Thanks a lot for the quick response.
OriginalGriff 4-Mar-14 4:52am    
Start by looking at the input files: what type are they?
Rajeshram009 4-Mar-14 4:54am    
one xml and other one is xsl
Rajeshram009 4-Mar-14 5:52am    
hi,
Now i zipped a PDF having 26 Mb.after zipped it is changed to 23.2.This is not sufficient for me.I need to change to half of the original size.

Any algorithm is there...
OriginalGriff 4-Mar-14 5:59am    
No.
PDF files are not compressed, but they can contain compressed format data (such as images and so forth) which will not compress further.

There is no "magic algorithm" which will allways allow you to compress a file by any fixed percentage: otherwise we would just have to use it repeatedly and send a count of the number of compressions along with a tiny file instead of transferring 700mb video files from Netflix...

What are you trying to do? why do you need to compress all files by 50%?

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