android 获取图片绝对地址

 
   
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;


}

你可能感兴趣的:(android)