I have a lot of operations involving generating a BufferedImage object using a third-party library and saving it to a jpg file. Sometimes one processing can have over 10,000 such savings. Currently I'm using ImageIO.write(image, "jpg", file)
directly but the performance is not very satisfactory.
I'm wondering if I can use direct ByteBuffer to make disk writing faster? I'm thinking about putting the BufferedImage into a direct ByteBuffer and finally save to disk using a FileChannel. I didn't find a way to do so. I wonder how can I put a BufferedImage to direct ByteBuffer? Some example code would help a lot.