byte[]与InputStream互转 博客分类: Java javainputreambyte[]ByteArrayOutputStream
程序员文章站
2024-02-24 20:42:46
...
InputStream转byte[]
private byte[] InputStreamToByte(InputStream is) { try { ByteArrayOutputStream bytestream = new ByteArrayOutputStream(); int ch; while ((ch = is.read()) != -1) { bytestream.write(ch); } byte imgdata[] = bytestream.toByteArray(); bytestream.close(); return imgdata; } catch (IOException e) { return null; } }
byte[]转InputStream
byte[] data; InputStream is = new ByteArrayInputStream(data);
上一篇: Java Web 登录页面的实现代码实例
下一篇: C#获取图片的后缀名解析