salut

dans une application c/s,
j'utilise NIO pour envoyer du texte
tous les clients reçois le texte sans problème

maintenant je voudrais aussi être en mesure d'envoyer des fichiers (images) au client (l'image s'afficherait sur un panel du client)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
ByteBuffer buffer = ByteBuffer.allocate( 4096 );
...
...
private void envoyerATous ByteBuffer bb ) {
        for (Enumeration e=sockets.elements();
        e.hasMoreElements();) {
            Socket socket = null;
            try {
                socket = (Socket)e.nextElement();
                SocketChannel sc = socket.getChannel();
                bb.rewind();
                while (bb.remaining()>0) {
                    sc.write( bb );
                }
            } catch( IOException ie ) {
                closedSockets.add( socket );
            }
        }
    }

j'envois le texte... mais comment faire pour envoyer un fichier?
niveau client, comment il sera que c'est un fichier et non du texte?

merci