在android工程下的assets下存放了一个文件(如:data.php),我想读取这个文件,将读出的数据存到byte a[]数组中,想要利用AssetManager的open()方法解决~我想这应该是个很简单的问题吧~希望大家耐心的帮我解决~
------解决方案--------------------
借花献佛,tongyu75写的,帖子出处http://topic.csdn.net/u/20100415/09/e5434851-6bde-4ba1-bdbe-dd7dc622ac6b.html?seed=425312877&r=64680621#r_64680621
try {
AssetManager a = getAssets();
InputStream inputStream = a.open("1.txt");
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[1];
while(inputStream.read(bytes) != -1) {
arrayOutputStream.write(bytes);
}
arrayOutputStream.close();
inputStream.close();
} catch(IOException e){
System.out.println("文件有误Erroe");
}