我没有遇到任何例外,但是当我跑步时......
InputStream deckFile = context.getAssets().open("cards.txt");
然后,deckFile.read() 返回-1。该文件位于正确的文件夹中,并且不为空。
这应该是世界上最简单的事情了……
编辑:AssetManager 确实列出了“cards.txt”,所以这不应该是问题。
尝试下面的代码行
InputStream is = getAssets().open("test.txt");
int size = is.available();
byte[] buffer = new byte[size]; //declare the size of the byte array with size of the file
is.read(buffer); //read file
is.close(); //close file
// Store text file data in the string variable
String str_data = new String(buffer);
可用方法返回资产的总大小...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)