SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

porting ICSharpCode.SharpZipLib.BZip2 to Java

Last post 07-06-2009 1:36 PM by rohans84. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 07-06-2009 1:36 PM

    porting ICSharpCode.SharpZipLib.BZip2 to Java

    My project has a requirement to convert an existing .net application to java. The app uses ICSharpCode.SharpZipLib.BZip2 library  for compression/decompression. This app would have to decompress existing data that was compressed using the .net code, hence I require a Bzip2 api in java that is absolutely compatible with SharpZipLib.BZip2.

    I tried org.apache.tools.bzip2 but I am getting null pointer exception inside the api when I am creating CBZip2InputStream object. On doing some research I found that the input stream is getting null. It is due to the compressed data? If yes then why does the same data gets uncompressed correctly in the .net version

    Am I using the API incorrectly? I have tried googling for information on using apache's bzip api but not finding much info.

     

    The code for uncompression looks like this in java

       public void bzip2Decompress (String compressedData, int bureauTxtBytesQty)
        {
      byte [ input = new byte[bureauTxtBytesQty];
      byte [ output = new byte [bureauTxtBytesQty];
      byte [ bytesUncompressed = new byte[bureauTxtBytesQty];
            int numBytesRead = 0;
            try
            {
       ByteArrayInputStream bais = new ByteArrayInputStream(
           new sun.misc.BASE64Decoder().decodeBuffer(compressedData));
           
       CBZip2InputStream inputStream = new CBZip2InputStream (bais);
                inputStream.read(bytesUncompressed, 0, bureauTxtBytesQty);
             inputStream.close();
       String uncompressedText = new String(bytesUncompressed);
       System.out.println("Uncompressed - " + uncompressedText);
            }
            catch (IOException ex)
            {
                ex.printStackTrace();
            }
        }

Page 1 of 1 (1 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.