Search code examples
androidxamarinbzip2

Using BZip2 in Xamarin


I am trying to read from a file, and I want to use Bzip2InputStream to do it. When i try to run my application it runs fine untill the code reaches the creation of the inputstream. At wich point it keeps running, but nothing happens and roughly every second the application output reads:

[Mono] GC_MINOR: (Nursery full) pause 5.67ms, total 6.16ms, bridge 0.00ms promoted 192K major 1152K los 1075K

Is there an alternatives I do not know about? I am doing something stupid? Thanks for any help!

The code is as follows.

using Ionic.BZip2;

namespace ActionBarTest
{
public class CoverageElement
{

}
public class Coverages
{
    private List<string> ChartNames = new List<string> ();
    private List<CoverageElement> m_Coverages;
    private BZip2InputStream bz2Stream;

    public Coverages(Stream compressedCoverage)
    {
        try{
        bz2Stream = new Ionic.BZip2.BZip2InputStream(compressedCoverage);
        }
        catch (Exception error){
        }


        using (BinaryReader b = new BinaryReader (bz2Stream)) {
            int t1 = b.ReadInt32 ();
            Console.WriteLine ("krøll i binaryreader" + t1);


            int noOfElements = b.ReadInt32 ();
            for (int i = 0; i < noOfElements; i++) {

                char[] t = b.ReadChars (8);
                ChartNames.Add (new string (t));

            }
        }

    }
}

}


Solution

  • I found out the answer, instead of sending the stream directly from the webclient result I needed to make a memorystream from the webclient result, and use that.