InputStream、byte[] 互转
InputStream转byte[]
private byte[] getBytesFromInputStream(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;
}
byte[]转InputStream
byte[] data; InputStream is = new ByteArrayInputStream(data);
http://mingkg21.javaeye.com/blog/431067
| Print article | This entry was posted by Herbert on 2010/03/31 at 17:44, and is filed under MyLife. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |