I am working on a Java program that should send an image (preferably in PNG format, although I could possibly use a different format if necessary) over the network. The logical way to do this, of course, is to first send the length of the PNG image data, and then the data itself. Problem: I don't see any method in ImageIOor anywhere else that will give me the length of the image data. Is this somewhere in the Java 1.6 standard library?
I know that I can just write it in ByteArrayOutputStreamand get the length of the resulting array, but before resorting to this, I wanted to make sure that I did not miss something inline. In addition, it makes an extra copy of the image data, which I would prefer not to do if it is not needed.
source
share