You are here

Files compression in Java MIDlet

Showcase, October 25, 2018 - 11:54am, 94 views

 

The purpose of this demo is to provide the example of files compression in Java MIDlet and to demonstrate the potential benefits.

For this applicationI have used compress-j2me library downloaded from here: https://github.com/igorgatis/compress-j2me

The code is very simple and does not require any adaptations. It provides 2 types of compression: GZIP and LZC. Please note that this library does not create archives but just can reduce the size of a single file.

The demo MIDlet produces 4 file on the module’s FFS – two compressed files and two decompressed files. It also needs a test file with the name ‘data_to_compress.txt’ to be provided on the main A: drive of the module. It can be any file of any size, just please take into consideration the storage size of the module.

Below is the example application output for the text file compression. It was possible to reduce the file size over four times.

 

[INFO] CompressExample: startApp

[INFO] ################# GZIP compression #################

[INFO] Compressing 'data_to_compress.txt' file and storing as 'compressed_GZIP_data.txt.gz'

[INFO] Uncompressing 'compressed_GZIP_data.txt.gz' file and storing as 'uncompressed_GZIP_data.txt'

[INFO] ################# LZC compression #################

[INFO] Compressing 'data_to_compress.txt' file and storing as 'compressed_LZC_data.txt.z'

[INFO] Uncompressing 'compressed_LZC_data.txt.z' file and storing as 'uncompressed_LZC_data.txt'

[INFO] ################# Statistics #################

[INFO] Original file size: 6.42 MB

[INFO] GZIP compressed file size: 2.54 MB

[INFO] LZC compressed file size: 1.48 MB

[INFO] CompressExample: destroyApp

 

I have used ELS61 module for test.

I was able to uncompress the output files on PC with 7-Zip application and read the content.

 

Bartłomiej Gemalto Moderator