一直在寻找如何从.twa文件中读取数据,但是找不到任何东西。
我有包含数据的.twa文件,它们位于android项目目录中的资产文件夹中。
即指针文件-> xyz.twa
我想从这些具有.twa扩展名的文件中读取数据。
如果有人对这些文件有任何了解,以及如何阅读这些文件,请与我分享您的知识。这会有很大帮助的。
发布于 2017-04-27 08:17:26
尝试一下,它将帮助您打开.twa文件。这就是我对我的文件所做的
先有ByteArrayInputStream
private ByteArrayInputStream file_hnd;现在尝试将文件打开为
try {
{
InputStream fip = null;
)
fip = getAssets().open("My Files/" + file_name);//Your driectory and file name
/* else
{
fip=new FileInputStream(f);
}*/
byte[] b = new byte[fip.available()];
fip.read(b);
file_hnd = new ByteArrayInputStream(b);
fip.close();
file_hnd.mark(file_hnd.available() + 1);
return true;
}
} catch (Exception e) {
e.printStackTrace();
}现在,您的ByteArray i.即file_hnd拥有该文件中的所有数据。因为阅读我做了这个
try {
file_hnd.reset();
int chars, i = 0, index = 0;
while ((chars = file_hnd.read()) != -1) {
aDes[index++] = (byte) chars;//Do your reading here
}
} catch (Exception e) {
e.printStackTrace();
}希望这能帮到你。
https://stackoverflow.com/questions/43651770
复制相似问题