File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java Micro Edition and the fly likes How to Compress TextMessages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "How to Compress TextMessages" Watch "How to Compress TextMessages" New topic

How to Compress TextMessages

Umashanthi Pavalanathan

Joined: Feb 15, 2007
Posts: 18
I want to know how to compress and send a large amount of characters in one SMS and how to read the compressed SMS from the receipent's phone.
If you have any idea please share yours...
Thanks in Advance,
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41132
SMS are limited to about 160 characters, so I don't think you'll be able to send a "large amount" of text.

Ping & DNS - my free Android networking tools app
Umashanthi Pavalanathan

Joined: Feb 15, 2007
Posts: 18
Hi Ulf Dittmer ,
Thank you for your reply.
But I heard that we can compress & send SMS having more than 160 characters in one SMS using JavaME.
But I am not sure.
Thanks again,
Eduardo Marques
Ranch Hand

Joined: Feb 19, 2005
Posts: 231
A SMS message may be encoded in a long SMS using different SMS segments.
The WMA specification states that at least 3 segments must be supported by an implementation, which gives, depending on the encoding:

GSM-7 bit (ASCII 7-bit) : 435 chars
Binary data (ie binary messages): 400 bytes
Unicode text: 198 messages

See page 28 of appendix A of specs at

You can query the number of segments in a SMS message, by using the following code:


Eduardo Marques
Get ready for your SCMAD certification at - See what all the buzz is about ...
Eduardo Marques
Ranch Hand

Joined: Feb 19, 2005
Posts: 231
But note that a device may support more than 3 segments, so these values are minimum guaranteed bounds ...

I doubt however that you may be able to send more than 500 to 1000 chars, so it's wise to compress your data somehow.

Also, use BinaryMessage, not TextMessage if your data scheme does not require text information. The character set in use by the phone (eg if Unicode) may decrease the message capacity heavily.
Sayan Jaipan

Joined: Jun 05, 2002
Posts: 3
Use GZip library to compress text string then set payload text with that compressed string.
Receiver need to install a client that support unzipped text message.(J2me + specific port, symbian + native sms inbox)
[ July 29, 2007: Message edited by: Sayan Jaipan ]
It is sorta covered in the JavaRanch Style Guide.
subject: How to Compress TextMessages
Similar Threads
How to detect incoming SMS
WA #1.....word association
compress jpg image file
JSP page with js file compression
String compression