• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Compression Algorithm

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys, I am coding a certain Swing application. This application is capable of saving data as files, which is a very common feature. However, I have a little problem here.

After generating the saved file, I need to be able to open this file in a J2ME application. As a result, I will like to have this saved file consume as little space as possible.

I was wondering if you experts out there have coded some sort of compreion algorithm. If yes, how does the algorithm work?

I need to create my own compression library, because most of the J2SE capabilities cannot be found in J2ME.

Thanks a lot for any help in advance.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a special J2ME forum.

I wonder: doesn't the j2me-technique use jar-s?
Which is a kind of zip. Can't you use it?

What kind of data do you store? Text? A limited set of lexical values? Different encodings? Binary data?
 
Liang Anmian
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My file stores BOTH text and binary data. I wonder if the Huffman Compression will work well in this scenario.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Liang Anmian:
My file stores BOTH text and binary data. I wonder if the Huffman Compression will work well in this scenario.

Probably not - Huffman coding usually doesn't give you more than 30%-ish on text, less on binary data. You're probably better off with an LZ* family algorithm; they still need only limited memory footprint (suspect ~20K-ish) and achieve much better compression. Follow them with an entropy coder such as Huffman for even better compression rate; this is how most compressed archive formats work. Avoid LZW if you're worried about patent issues. This Java LZSS implementation looks useable and unencumbered by patent or licensing restrictions, but be warned I have no experience with it whatsoever.

This is assuming that J2ME doesn't have inbuilt gzip/zip/jar support like J2SE has (don't ask me, I'm a big iron J2EE guy). If it does, it's simple: use that. A gzip stream would serve you nicely.

Hope this helps,

- Peter
[ August 21, 2004: Message edited by: Peter den Haan ]
 
Attractive, successful people love this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic