我没有任何例外,但是当我跑…
@H_404_2@InputStream deckFile = context.getAssets().open("cards.txt");
然后,deckFile.read()返回-1.该文件位于正确的文件夹中,并且它不为空.
这应该是世界上最简单的事情……
编辑:AssetManager确实列出了“cards.txt”,因此不应该是问题.
解决方法
尝试下面的代码行
@H_404_2@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);
可用方法返回资产的总大小…