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

  • SEARCH
  • Home
  • 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 369459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:55:18+00:00 2026-05-12T13:55:18+00:00

I have a Base64 string that’s been gzipped in .NET and I would like

  • 0

I have a Base64 string that’s been gzipped in .NET and I would like to convert it back into a string in Java. I’m looking for some Java equivalents to the C# syntax, particularly:

  • Convert.FromBase64String
  • MemoryStream
  • GZipStream

Here’s the method I’d like to convert:

public static string Decompress(string zipText) {
    byte[] gzipBuff = Convert.FromBase64String(zipText);

    using (MemoryStream memstream = new MemoryStream())
    {
        int msgLength = BitConverter.ToInt32(gzipBuff, 0);
        memstream.Write(gzipBuff, 4, gzipBuff.Length - 4);

        byte[] buffer = new byte[msgLength];

        memstream.Position = 0;
        using (GZipStream gzip = new GZipStream(memstream, CompressionMode.Decompress))
        {
            gzip.Read(buffer, 0, buffer.Length);
        }
        return Encoding.UTF8.GetString(buffer);
     }
}

Any pointers are appreciated.

  • 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-12T13:55:18+00:00Added an answer on May 12, 2026 at 1:55 pm

    For Base64, you have the Base64 class from Apache Commons, and the decodeBase64 method which takes a String and returns a byte[].

    Then, you can read the resulting byte[] into a ByteArrayInputStream. At last, pass the ByteArrayInputStream to a GZipInputStream and read the uncompressed bytes.


    The code looks like something along these lines:

    public static String Decompress(String zipText) throws IOException {
        byte[] gzipBuff = Base64.decodeBase64(zipText);
    
        ByteArrayInputStream memstream = new ByteArrayInputStream(gzipBuff);
        GZIPInputStream gzin = new GZIPInputStream(memstream);
    
        final int buffSize = 8192;
        byte[] tempBuffer = new byte[buffSize ];
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        while ((size = gzin.read(tempBuffer, 0, buffSize)) != -1) {
            baos.write(tempBuffer, 0, size);
        }        
        byte[] buffer = baos.toByteArray();
        baos.close();
    
        return new String(buffer, "UTF-8");
    }
    

    I didn’t test the code, but I think it should work, maybe with a few modifications.

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

Sidebar

Related Questions

I have a base64 encoded string that I would like to convert into an
I have a binary that I want to convert to standard MIME-compliant base64 string.
I have a string that I'm encoding into base64 to conserve space. Is it
I have my canvas represented as a base64 string. I would like to pass
I have a Java Applet that is generating an image. Ultimately, I would like
I have an array dump that I want to compress into a string that
I have a Base64 encoded String that contains PDF data. Using the EncdDecd unit
I have base 64 encoded string that looks something like this. cuVrcYvlqYze3OZ8Y5tSqQY205mcquu0GsHkgXe4bPg= I have
I have a string that was salted, hashed with SHA-256, then base64 encoded. Is
I have this string that I get back from Adobe Presenter 7. It's called

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.