Compress and decompress data using GZip

Hello

I compress and decompress data on Blackberry 8100 device using the GZip algorithm.

I use following code:

try {           GZIPOutputStream gCompress = null;          try {               ByteArrayOutputStream compressByte = new ByteArrayOutputStream();               gCompress = new GZIPOutputStream(compressByte,9);               gCompress.write(inputstring.getBytes());                                                //gCompress.flush();                compressedBytes = compressByte.toByteArray();               System.out.println("compressedBytes : "                     + new String(compressedBytes));             compressedString = new String(compressedBytes);                         } catch (IOException ex) {              ex.printStackTrace();           }       } catch (Exception e) {         e.printStackTrace();        }

The server is unable to decompress data.

Help, please.

Thank you very much.

I think you do a byte to the conversion of the string which you should not do and which may be screwing up your data.  The output of compression is not likely to be easily represented by Unicode characters and you want to transmit the bytes, so I think that is not necessary.

This is a reformulated version of the sample in the API, which seems inaccurate, in any case: give it a try and remember that you can send the bytes, not characters.

public static byte[] compress( byte[] data ) {
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        GZIPOutputStream gzipStream = new GZIPOutputStream( baos,
                                                            GZIPOutputStream.COMPRESSION_BEST,
                                                            GZIPOutputStream.MAX_LOG2_WINDOW_LENGTH );
        gzipStream.write( data );
        gzipStream.close();
        return baos.toByteArray();
    }
    catch(IOException ioe) {
        return null;
    }
}

Tags: BlackBerry Developers

Similar Questions

  • Question about compression and decompression

    I see that the UTL_COMPRESS package allows you to compress and decompress data binary (RAW, BLOB and BFILE).

    My question is: Y at - it a utility that will do something similar for the VARCHAR2 data?

    Thank you

    Thomas

    You can just use UTL_RAW. Cast_To/From_Varchar2?

    Gerard

  • How to compress and decompress the file in mac

    How to compress and decompress the file in mac

    I will use third party software to do this.

  • How to compress and decompress the host

    Sorry if this sounds like a newbie question - but I am.

    Because of bad communications, I would like to transfer files from a customer in the data store ESX4i in zip file.  for example, the virtual machine is 80 GB but when zipped it's less than 8 GB.  I can't depend on 80GB transfer over the network potentially for hours without getting dropouts etc..

    I know that I can transfer the file zip through the CLI (alive).  My question, once it is there, how I decompress the file.

    I think I can drop towards the mode not supported on 4i ESX host and use gunzip - I can do the equivalent using the CLI or the vsphere client?

    Similarly, can I zip the contents of a data store folder and simply transfer the zip file?

    I know he supports the two ESX(I) 4.0, do not know if there are major changes of this 4.1 support, you'll want to test and see. The documentation is probably the next place to look and there is actually a forum for questions about the ovf tool - http://communities.vmware.com/community/vmtn/vsphere/automationtools/ovf

    =========================================================================

    William Lam

    VMware vExpert 2009,2010

    VMware scripts and resources at: http://www.virtuallyghetto.com/

    Twitter: @lamw

    repository scripts vGhetto

    Introduction to the vMA (tips/tricks)

    Getting started with vSphere SDK for Perl

    VMware Code Central - Scripts/code samples for developers and administrators

    VMware developer community

    If you find this information useful, please give points to "correct" or "useful".

  • acquire, analyze, and log data using the technique of the statemachine

    I'm technical state machine learning to develop code to acquisitoin of data and logging. I think I wrote the correct code for this purpose, but I couldn't have done the following:

    All the values(>0) of warning should appear on table 1 d on the façade. The code is written only the first value.

    All values must be recorded using to write to the palette of the spreadsheet and written on the excel sheet. Code is only writing first value.

    I wonder what is the error. The code I created is attached, I would be grateful if someone fix the code and post in response.

    Thank you in advance for help

    See you soon

    Hi kwaris,

    "What is the error": well, you use a lot of unnecessary conversions. Really a lot of...

    Why do you convert a dynamic scalar value, then convert to table, then index an element of the array? Why convert to dynamic when everything you needis a simple "build table" node?

    OK, I've included a shift register where you will store your table. It of just a simple 'how to', but not the best solution for all cases. But it should give you a clue...

  • I messed up compress and decompress files Win XP. Can I get help?

    I don't know that I've caused this mess somehow by deleting or disabling something somewhere. Can someone clue me?

    My computer has lost the association. ZIP files and he wants to use a program WinZip he wants to sell me.

    I googled the hell out to try to solve this problem and stuff talking about click with the right button on any file and choose something to compress. But is not there at all. If I try to open this file, a box pops up wanting me to use a trial version of WinZip or purchase.

    After fighting this mess a day for a week, I'm almost ready to throw in the towel and a pc to Apple. But I'm not a silencer!

    So can someone please copy / paste in, or simply write me a quick lesson on the implementation of this compressed file (zipped) and then zip a file inside to allow the smaller space of storage or for emailing?

    I'm no reader don't link, so please don't not all component software snap-in all the links to me like this http://support.microsoft.com/kb/306531. For some reason, my head just started twisting and even after trying to make sense out of what he tells me to do, I'm still lost.

    Help!

    I was able to open a zip file that I found online somehow, somehow after that double click I wanted to just open it with WinZip. Somehow, I recorded it on my desk and then I think clicked and selected open with and he offered me something (compressed) standard Windows. But I don't seem to get that now.

    I would of course go to my Docs and a kind of zip file and then send it to myself and then unzip the attachment. But I can not yet understand how to do the 1st step. I'm feeling braindead, but actually I was quite able technically my life. HOW frustrating1

    CAN I HAVE IT PLEASE HELP!

    Yes, WinZip is a commercial product, but you can use 7-zip, which is both free and much better than the built-in Windows file archiver.

    To restore the native Windows XP file compression utility, see--> http://windowsxp.mvps.org/zipfldr.htm

    These directions are pretty clear, but if you have problems, after return and tell what is confusing you.  If it still does not, after the full text of any error message you get, without paraphrasing.

  • When I try to unzip a file I have by default Adobe Reader, which is the wrong program. I have Windows Vista Home Premium. I need to download a software to compress and decompress compressed files?

    I run Windows Office 2007. And find that when trying to extract a .zip file, I get Adobe Reader who tells me to can not read the file (of course). So, where's the decompression of files program. I need to download one?

    Hello

    1st 3 here should fix you up

    How to restore Vista built-in ZIP files Support
    http://www.Vistax64.com/tutorials/65254-zip-file-support-restore.html
    How to enable or disable the files compressed in Vista
    http://www.Vistax64.com/tutorials/93827-zip-file-compressed-folders.html
    Restore the Type Associations by default Vista file extensions
    http://www.Vistax64.com/tutorials/233243-default-file-type-associations-restore.html

    ---------------------------------

    How Unassociate a Type of Extension file in Vista - and a utility to help
    http://www.Vistax64.com/tutorials/91920-unassociate-file-extention-type.html

    How to restore files ZIP integrated into Vista Supporthttp://www.vistax64.com/tutorials/65254-zip-file-support-restore.htmlHow to enable or disable the compressed foldershttp://www.vistax64.com/tutorials/93827-zip-file-compressed-folders.html
    Restore and return the file Association in Windows Vista if Original
    http://www.mydigitallife.info/2008/06/22/restore-and-reset-file-association-in-Windows-Vista-back-to-original-default/

    Reset and Fix Broken Windows Vista file Ext and Type Associations (include EXE, COM, SYS, ZIP, LNK,
    Folder, drive)
    http://www.mydigitallife.info/2008/06/22/reset-and-fix-broken-Windows-Vista-file-ext-and-type-associations-include-exe-com-sys-zip-lnk-folder-drive/

    For Windows Vista file association problems
    http://www.Winhelponline.com/articles/105/1/file-association-fixes-for-Windows-Vista.html

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • How to compress and decompress with Windows 10?

    Hello

    Y at - it an output of feature box in 10 Windows to extract and compress files?

    Thank you

    Hello

    Thanks for posting your query in Microsoft Community.

    You can zip (compress) a file so that it takes less space. This functionality is similar to that in previous versions of Windows.

    Zip (compress) a file or folder

    1. Click the icon of the file Explorer in the taskbar or press the Windows key + E together, to open the file Explorer.
    2. Select the file or folder, press or click on Shareand then tap or click Zip in the Ribbon toolbar.
      (System could take a long time to compress the folder)

    Unzip (extract) the files or folders from a compressed folder

    1. Click the icon of the file Explorer in the taskbar or press the Windows key + E together, to open the file Explorer.
    2. Double-click on the zip file. Opens in a new window.
    3. Click on extract to , and then select the destination folder.
    4. Follow the steps on the screen to complete the process.

    Hope this information is useful. Let us know if you need more help, we will be happy to help you.

  • Get and set data using the ActionScript class

    Hello

    I use the ActionScript class to store the user name and password when the user logs


    com package
    {
    public class Login
    {
    public function Greeter (initialName:String = "")
    {
    }

    public var uname:String;
    password public var: String;

    }
    }

    Inside the Componet Login form, I am creating the object of this class of connection and affecting the data as shown in it

    var logincomp:Login = new login());

    logincomp.uname = UnameTI.text;
    logincomp. Password = PassTI.text;


    I need these data within an another CustomComponent, is it possiblke to access these data within an another componnet.

    Can I do this?


    var logincomp:Login = new login());

    var str:String = new String();

    Str = logincomp.uname;


    Please me tips


    I know it's possible with recording and Dispatching Evenets
    However, I'm not interested to use DEMONSTRATIONS. I'm using FLEX 3

    Please advise me if this is possible.

    THnaks in advance.

    Thanks for helping me learn Flex quickly.

    Hello

    You use a Singleton class as (class ModelLocator) If Yes, then you can put a single instance of your connection class in this class so that you can access this instance in the world in any component (infact with the app).

    Declare an instance of the connection object in the Singleton class like below

    var logincomp:Login = new login());

    Set the values in a single component, and you can access the values in the other component.

    The sample class Singleton as shown below...

    package com.model
    {

    [Bindable]
    public class ModelLocator
    {
    private static var instance: ModelLocator;
     
    public var logincomp:Login = new login());
     
    public void ModelLocator()
    {
    If (instance! = null)
    {
    throw (new Error ("cannot only one instance of ModelLocator"));
    }
    }
    Public Shared function getInstance (): ModelLocator
    {
    if(instance == null)
    {
    instance = new ModelLocator();
    }
    return instance;
    }
    }
    }

    If this post answers your question or assistance, please mark it as such.

    Thank you

    Jean Claude Chari

  • I have a problem with file compression and then not be able to extract their share at a later date

    original title: file compression

    I am running Vista Home Premium on my laptop. I have problems with file compression and then not be able to extract their share at a later date. For example, I sent a file compressed to my instructor and she pointed out that she had a .zipx extension and the fact that she was unable to extract the files of ranking. Can someone help me with this problem?

    Hello

    1. do you have a third party compression/extraction of software installed on your machine?
    2. do you get an error message when you try to extract the files?
    3. is the relevant question for the particular file type?
    4. don't you make changes to your computer before the problem?

    Follow the steps and check if they help.

    Step 1:

    Open zip files is to open the folder and drag the content to another folder.

    See article:
    Compress and uncompress files (zip files)

    Step 2:

    If you have a third party software to Compress/decompress, I'd Uninstall it employs the way Windows compression and decompression of files/folders and see if they help.

  • When I send a text message and mobile data are off, it is not given, but I do not see this message for a few minutes. I can then refer using "send as a text message. How can I 'send as a text message' in the first place?

    When I send a text message and mobile data are off, it is not given, but I do not see this message for a few minutes. I can then refer using "send as a text message. How can I 'send as a text message' in the first place?

    Disable the iMessage?

  • I have a lot of documents and data use on my iPhone 6 iOS. 9.1.2.

    I have an Iphone 6 and at the moment my use of documents and the date is much (2.1 GB) or even hard I've just reset it.

    Does anyone recognize this problem? Before I reset my use of data and documents has been about 5 gigabytes.

    May I ask where you're going in your settings to view this use?

  • measure the angular speed, angle and trigger using a gyroscopic sensor breakout board and LabView data acquisition

    How to measure the angular velocity, the angle and trigger using a gyroscopic sensor breakout board and LabView data acquisition?

    There is a single channel data acquisition code which measures the angular velocity, angle and flexibility using a gyroscopic sensor breakout board and acquisition of LabView data attached to this, I need a help to creat two-channel data acquisition code?

    Hello

    Attached is a vi that you can use in order to read the measured angular position of an encoder.

    If you need more examples on the tasks that you can develop with NOR-DAQmx and LabVIEW, you just need to open LabVIEW and click Help > find examples > Input and Output material > DAQmx > entry counter.

    Kind regards

  • you want to send data using labVIEW to arduino using write visa and the process and to take action using arduino. A

    I want to send data using labVIEW to arduino using write visa and the process and to take action using arduino. After that, I want to arduino to send out necessary via a serial port to labVIEW which should be read using visa read and store in a chain. While I am able to write or read both individually, I can't do it consecutively. I used advanced read and write vi for checking my code, but nothing is helping. The wrong bed 'time delay before execution. " Please let me know where I can go wrong. Also is it possible to write code for hx711 using labVIEW

    1. you need not "\n" on your orders println().  This command adds an end of line character already in the message.

    2. you get the error because you have a loop around your reading.  After the first reading (well technically, the second because of you add an extra line end character), there is nothing left in the port.  As a result, you will get the timeout.

    3. you should really consider using a Structure of the event.  This way you just don't write and read when you press the Write button and you can also use the structure of the event to make the loop to stop.  I also go up to close the port inside the stop-> value Change event.

  • I am new to the ethernet communication using labview. I don't have any material. I have two laptop, I need to send and receive data through these 2 portable by using labview. Kindly help me on this.

    I am new to the ethernet communication using labview. I don't have any material. I have two laptop, I need to send and receive data through these 2 portable by using labview. Kindly help me on this.

    Dennis has already said: for a direct PC - PC connection, you need a cross over cable. If you connect through a router or a switch, you use a standard cable.

Maybe you are looking for

  • Satellite A300-1EH - where to find the key for Microsoft Works?

    Satellite A300-1EH My laptop has been repaired. Exchange service throughout the system. I have serious problem since then.The new version of Microsoft Works requires me 25 - the key of the product registration. I don't have him. Where can I get this

  • Using the code scanner barcode

    Hai Experts We created an application for the trial Board of horn using LabVIEW, almost our project is now finished the client gave us another task that the need to analyze the sample number through bar codes and write this number in the report... Th

  • Fix KB925681 for xp sp3 will work on sp2?

    Hello! I downloaded the patch KB925681. I run xp sp2 but since they had no option download for sp2 and was only for sp3 I had to download the sp3 one and to my amazement it completely installed on my system. My question is it will show its effect on

  • my computer shuts down when not in use before the backup is performed. How do stay on

    When you back up the computer I do not. Then he stops before the backup is made making it incomplete, it's Vista

  • resolution problem with my monitor every time I turn on

    I have a monitor to display wide w1907 h p on nvidia gforce7050/nvidia nforce 6101.2 weeks I had restore the desktop pc top of page back to default settings since then every time I turn on the screen starts to the resolution of the game and then afte