IOException while reading from InputStream

前端 未结 4 1437
孤独总比滥情好
孤独总比滥情好 2020-12-06 02:11

I\'m running into a strange problem while reading from an InputStream on the Android platform. I\'m not sure if this is an Android specific issue, or something I\'

相关标签:
4条回答
  • 2020-12-06 02:32

    Changing the file extension to .mp3 to avoid the file compression does work, but the APK of the app is much bigger (in my case 2.3 MB instead of 0.99 MB).

    Is there any other way to avoid this issue ?

    Here is my answer: Load files bigger than 1M from assets folder

    0 讨论(0)
  • 2020-12-06 02:32

    You are correct, in that there is a certain size limit for extracting files. You may wish to split larger files into 1MB pieces, and have a method by which you know which files are made of which pieces, stitching them back together again when your app runs.

    0 讨论(0)
  • 2020-12-06 02:34

    (my post to android-developers isn't showing up, so I'll try reposting it here)

    IIRC, this problem comes from trying to access files that were compressed as part of building the APK.

    Hence, to work around the issue, give it a file extension that won't be compressed. I forget the list of what extensions are skipped, but file types known to already be compressed (e.g., mp3, jpg) may work.

    0 讨论(0)
  • 2020-12-06 02:45

    You can compress the file for yourself with GZIP and unpack it with GZIPInputStream class.

    http://developer.android.com/reference/java/util/zip/GZIPInputStream.html

    0 讨论(0)
提交回复
热议问题