Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6821613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:33:55+00:00 2026-05-26T21:33:55+00:00

I found this article about simple proxy server implemented in JAVA: http://www.java2s.com/Code/Java/Network-Protocol/Asimpleproxyserver.htm The code

  • 0

I found this article about simple proxy server implemented in JAVA:

http://www.java2s.com/Code/Java/Network-Protocol/Asimpleproxyserver.htm

The code simply gets some stream from the client, after sends it to the server and after it gets stream from the server and sends the response to the client. What I would like to do is to compress this streams before it is sent and decompress after it is received.

I found the class GZIPInputStream but I’m not sure how to use it and what I found on internet didn’t help me. I either didn’t understand that so much or it was not a good solution for me.

My idea is too that but I’m not sure if its ok:

final InputStream streamFromClient = client.getInputStream();
final OutputStream streamToClient = client.getOutputStream();
final InputStream streamFromServer = server.getInputStream();
final OutputStream streamToServer = server.getOutputStream();

InputStream gzipStream = new GZIPInputStream(streamFromClient );
try
{
        while ((bytesRead = gzipStream.read(request)) != -1)
       {
                    streamToServer.write(request, 0, bytesRead);
                    streamToServer.flush();
        }
}
catch (Exception e) {
System.out.println(e);
}

Now the data sent to the server should be compressed before sending (but I’m not sure if it’s a correct solution). IS IT?

Now imagine the server sends me the compressed data.
So this stream:

final InputStream streamFromServer = server.getInputStream();

is compressed.

How can I decompress it and write to the

final OutputStream streamToClient = client.getOutputStream();

Thanks for the help, guys!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:33:56+00:00Added an answer on May 26, 2026 at 9:33 pm

    Read the javadoc of these streams : http://download.oracle.com/javase/6/docs/api/java/util/zip/GZIPInputStream.html and http://download.oracle.com/javase/6/docs/api/java/util/zip/GZIPOutputStream.html.

    GZIPOutputStream compresses the bytes you write into it before sending them to the wrapped output stream. GZIPInputStream reads compressed bytes from the wrapped stream and returns uncompressed bytes.

    So, if you want to send compressed bytes to anyone, you must write to a GZIPOutputStream. But of course, this will only work if the receiving end knows it and decompresses the bytes it receives.

    Similarly, if you want to read compressed bytes, you need to read them from a GZIPInputSTream. But of course, it’ll only work if the bytes are indeed compressed using the same algorithm by the sending end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this on net in google search and see article here: http://www.thatcssguy.com/limit-your-divs/ See
I recently found an article online that told me about this: RewriteRule ^mock-up/([^/]+)/([^/]+) /mock-up/index.php?page=$1&section=$2
just was reading this article http://highscalability.com/blog/2010/3/23/digg-4000-performance-increase-by-sorting-in-php-rather-than.html And found this nice article http://wiki.apache.org/cassandra/DataModel I just
i found an article about self modifying code and tried to do some examples,
I found an article on About.com that tells you how you can manage your
To this day, I have not found a great article about expressions - and
I have found a number of articles such as this one that talk about
I found this article on how to manipulate the rendering sequence of asp.net controls.:
I've found this MSDN article that explains how to monitor processes and services with
I found this in an article on Multithreaded Apartments, but can’t find a definition

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.