![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Android™) Uncompress a Gzip File to a StringSee more Gzip ExamplesThis example demonstrates how to use the The method reads the compressed file, decompresses the data, and then converts the resulting bytes into a string using the specified character set (in this case, UTF-8). It is important to specify the correct character set that matches the original encoding of the text. If the wrong character set is used, the resulting string may contain incorrect or unreadable characters. This method is convenient when working with compressed text data that needs to be processed directly in memory without writing to a file.
// Important: Don't forget to include the call to System.loadLibrary // as shown at the bottom of this code sample. package com.test; import android.app.Activity; import com.chilkatsoft.*; import android.widget.TextView; import android.os.Bundle; public class SimpleActivity extends Activity { private static final String TAG = "Chilkat"; // Called when the activity is first created. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // This example demonstrates how to uncompress a Gzip (.gz) file // that contains text and return the result as a string. CkGzip gzip = new CkGzip(); // The Gzip file to be uncompressed: String gzPath = "example.txt.gz"; // Uncompress the file and interpret the result as UTF-8 text: String text = gzip.uncompressFileToString(gzPath,"utf-8"); if (gzip.get_LastMethodSuccess() == false) { Log.i(TAG, gzip.lastErrorText()); return; } Log.i(TAG, "Uncompressed text:"); Log.i(TAG, text); } static { System.loadLibrary("chilkat"); // Note: If the incorrect library name is passed to System.loadLibrary, // then you will see the following error message at application startup: //"The application <your-application-name> has stopped unexpectedly. Please try again." } } |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.