aspose file tools*
The moose likes Android and the fly likes decodeStream() OR Put large file in ASSETS folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "decodeStream() OR Put large file in ASSETS folder" Watch "decodeStream() OR Put large file in ASSETS folder" New topic
Author

decodeStream() OR Put large file in ASSETS folder

Ravi Delogico
Greenhorn

Joined: Jun 28, 2011
Posts: 14

Hi All,

Currently I am facing a very crucial problem. In my application I need to extract one zip file (always > 20 MB) into SD Card - along with the other tasks like copying the database, deleting other unnecessary files etc. But all this stuffs will be done only once - on first run of my application. Everything was working fine until client gave me a requirement to put this zip in assets folder. Now my application is getting force closed.

here is the problem and my attempts.

1. First I tried to open the file from assets by using

But I get NullpointerException on this line. On the other hand I am copying my database using this way only. I think this is because of the very large size of the file.

2. So I did another attempt to copy this file into SD Card before unzipping it. So I used following code.


By doing this my zip is getting copied successfully but after that another action I am performing. That action is - to get the image file name from DB and take the image from the Unzipped folder (after unzipping this file) at that time I am getting
bitmap size exceeds VM budget while on decodeStream exception while decoding stream. But this comes only once - I mean immediately after unzipping. After restarting the app this whole process is not getting repeated so only thing comes in picture is to get the image from sd card and set it. So it works fine.

And if I comment the above code (to copy file) and already put one zip in asset (for testing) then works fine. That means this code occupies more resources.

3. Then I tried to copy file using IOUtils. But for that also I need to open that zip to make the InputStream -

So again null pointer exception I am getting.
The situation seems like dead lock to me.

So what should I do to unzip this file. Please suggest me if you are getting my problem.

Ravi Delogico
Greenhorn

Joined: Jun 28, 2011
Posts: 14

Solved....thanks for viewing this post guys.

I googled and got that if your file size is very large then its better to put the extension .mp3 while copying it else it will not get opened and may give you nullPointerexception.

In my case, I was giving different destination file name than source file name while copying the file using IOUtils.copy(inputStream, outputStream, destFile). I was not aware with that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: decodeStream() OR Put large file in ASSETS folder