byte[] 跟 InputStream 相互转化

byte[] 和 InputStream 相互转化1. byte[] - InputStream????? byte[] b ?xxx??????InputStream is n

byte[] 和 InputStream 相互转化

1. byte[] -> InputStream

????? byte[] b =?xxx;

??????InputStream is = new ByteArrayInputStream(b);

?

2. InputStream -> byte[]

?? InputStream is = xxx;
???ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
???int ch;
???while ((ch = is.read()) != -1) {
????bytestream.write(ch);
???}
???byte[] b = bytestream.toByteArray();
???bytestream.close();