且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从BufferedImage获取InputStream?

更新时间:2023-11-06 21:27:34

如果您尝试将图像保存到文件,请尝试:

If you are trying to save the image to a file try:

ImageIO.write(thumb, "jpeg", new File(....));

如果您只想要字节,请尝试执行写入调用,但是传递一个ByteArrayOutputStream,然后您可以得到字节数组,并根据需要进行操作。

If you just want at the bytes try doing the write call but pass it a ByteArrayOutputStream which you can then get the byte array out of and do with it what you want.