您的位置:首页 > 移动开发 > Android开发

Android 获取assets的绝对路径

2013-12-31 16:34 791 查看
第一种方法:

String path = "file:///android_asset/文件名";

第二种方法:

InputStream abpath = getClass().getResourceAsStream("/assets/文件名");

若要想要转换成String类型

String path = new String(InputStreamToByte(abpath ));

private byte[] InputStreamToByte(InputStream is) throws IOException {

ByteArrayOutputStream bytestream = new ByteArrayOutputStream();

int ch;

while ((ch = is.read()) != -1) {

bytestream.write(ch);

}

byte imgdata[] = bytestream.toByteArray();

bytestream.close();

return imgdata;

}
http://www.cnblogs.com/sybz/archive/2011/12/17/2774565.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: