android 获取图片绝对地址
16lz
2021-01-23
String path ="";
InputStream abpath = getClass().getResourceAsStream("/assets/ic_launcher.png");
try {
path = new String(InputStreamToByte(abpath ));
} catch (IOException e) {
e.printStackTrace();
}
//文件流转Byte
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;
}
InputStream abpath = getClass().getResourceAsStream("/assets/ic_launcher.png");
try {
path = new String(InputStreamToByte(abpath ));
} catch (IOException e) {
e.printStackTrace();
}
//文件流转Byte
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;
}
更多相关文章
- Android 之 将RAW资源文件写入SD卡工具类
- Android 上传文件[转]
- 挂载android只读文件系统为可读写
- android 之 读取本地json文件返回string
- android中利用pull解析xml文件
- Memory Analyzer(MAT)打开android eclipse Dump内存文件出现 Unkno
- Android文件读写包含SDCard
- android 按纽状态配置文件