Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Compressed ByteArray to string and back, how to do it?

Community Beginner ,
Jul 12, 2017 Jul 12, 2017

I would like to transfer compressed data with the ByteArray, I can add object to the ByteArray, compress them and get a compressed string of the data.

But I don't know how to revert the process, if I have the compress string of data, how can load it in a byte array decompress it and get the data?

var hw1:String="Hello World"; //My test data

var ba1:ByteArray = new ByteArray();

ba1.writeUTFBytes(hw1); //add test data to byte array

ba1.deflate();  //compress the byte array

var ser:String = ba1.toString(); //serialize the byte array to a compressed string

var ba2:ByteArray = new ByteArray();

ba2.writeUTFBytes(ser); //how to revert the serialized byte array in a byte array again?

ba2.inflate(); //decompress the byte array

var hw2:String=ba2.toString() //it should return my test data "Hello World"

TOPICS
ActionScript
503
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation