I'm trying to make a client/server program where server sends a stream of images (5 to 10) and clients that plays them consecutively and repeats (to simulate a video).
I wrote the code where server send one image to the client using Image IO and the server receive and display it, but I have a problem in sending stream of images and I don't know if Image IO can send stream of images or not.
ImageIO doesn't stream anything by itself - how exactly are you using it? Can you post relevant excerpts of the client and server code?
My first reaction would be: create a ZIP file containing all images and send that. That's probably easier than coming up with a protocol that sends multiple consecutive files individually.
I see. There is no need for ImageIO here - it transforms files to BufferedImage objects, and then back to byte[] for streaming over the connection. You should just read from a FileInputStream, and then write to the connection directly.
You can, but then you need to come with some kind of protocol for client and server to use, so both sides know when one image is done, and the next one starts. That's why I suggested using a ZIP file, so that you'd have only a single file to send. This doesn't really have anything to do with using or not using ImageIO.
You can only use a ZipInputStream with a zip file, not with a directory. It is an InputStream like any other, you can use the read(byte[]) and read(byte[], int, int) methods to read its contents into a byte[] - the contents of which you can then stream to the connection.
If this was my problem, I wouldn't create a zip file at all. I would create a ZipOutputStream around conn.getOutputStream(), and then create ZipEntry objects for each file, and wrote the contents of the files directly to the ZipOutputStream.