Android 上 Assets 文件夹中的 InputStream 返回空 [英] InputStream from Assets folder on Android returning empty

查看:45
本文介绍了Android 上 Assets 文件夹中的 InputStream 返回空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有遇到任何异常,但是当我运行时...

I'm not getting any exceptions, but when I run...

InputStream deckFile = context.getAssets().open("cards.txt");

然后,deckFile.read() 返回 -1.该文件位于正确的文件夹中,并且不是空的.

Then, deckFile.read() returns -1. The file is in the correct folder, and it is NOT empty.

这应该是世界上最简单的事情了...

This should be the easiest thing in the world...

AssetManager 确实将cards.txt"列为存在,所以这应该不是问题.

The AssetManager is indeed listing "cards.txt" as being there, so that shouldn't be the problem.

推荐答案

问题是我的文件太大了,因为它的扩展名为.txt"而被压缩.通过将文件重命名为通常压缩的格式.mp3",没有问题

The problem was that my file was too big, and was being compressed because of it's ".txt" extension. By renaming the file to a format that is normally compressed, ".mp3", there was no issue

这篇关于Android 上 Assets 文件夹中的 InputStream 返回空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆