String path ="";
InputStream abpath = getClass().getResourceAsStream("/assets/ic_launcher.png");
try {
path = new String(InputStreamToByte(abpath ));
} catch (IOException e) {
e.printStackTrace();
}
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;
}
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;
}