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 Base64 String that represents a BitMap image. I need to transform
I have a textbox to display a very long Base64 string. The TextBox.Multline =
I have a string to encyrpt: $encryptThis = Super Secret Text; echo openssl_encrypt($encryptThis, 'aes-128-cbc',
I have this code for AES encryption, can some one verify that this code
So I have the user enter password to signup from the android app. Before
I am developing an application in java for a mobile platform. The program uses
I need to try to estimate the DISK size of a text string (which
This is a puzzle to me and I am really annoyed that I cannot
I am creating a jQuery / AJAX search script, and I am trying to

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.