compress and decompress string

I have a String encoded Base64 , and I need it to be compressed for sending the Socket.

and receiving it from socket want it to be decompress as before , the string encoded Base64 .

How can I make it??
Who is Participating?
objectsConnect With a Mentor Commented:
you can do something like this (where out is where you want to write the compressed data):

GZIPOutputStream gos = new GZIPOutputStream(out);

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

CEHJConnect With a Mentor Commented:
Why is the String encoded as Base64? Doing that inflates the size of what it was originally. The purpose of it is to render binary content able to be handled as a String.
When you compress it in the  manner suggested above, you will again get binary content, which will probably be larger than it was originally.
Are you communcations string-oriented, or binary-oriented?
gamjaradioAuthor Commented:
I communicates with string-oriented.

CEHJConnect With a Mentor Commented:
In that case, you should either:

a. get the byte array before it gets Base64-encoded and compress that, then Base64 encode
b. Base64-decode then apply a. above

If you can post an example Base64 string, preferably attached as a file, then we can give it a try
objectsConnect With a Mentor Commented:
the code I posted above will encode your string for you.
Do the reverse to decode it

let me know if you have any problems
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.