ok, merci.
Alors voila ce que j'ai fais :
1 2 3 4 5 6 7 8 9
| public class objet implements Serializable {
Object fichier = new Object();
public objet (Object o ) {
fichier = o;
}
public Object enregistrer () {
return fichier;
}
} |
Les modifs de Ma classe Serveur :
1 2 3 4 5 6 7 8 9 10
| ServerSocket socket = new ServerSocket ( port );
Socket soc = socket.accept();
System.out.println("Serveur créé, en attente du client");
URL url=new URL("<a href="http://mon-serveur.fr/but01.gif" target="_blank">http://mon-serveur.fr/but01.gif</a>");
Object image = url.getContent();
ObjectOutputStream oss = new ObjectOutputStream (soc.getOutputStream());
oss.writeObject (new objet(image)); //est-ce correct ??? |
Les modifs de Ma Classe client :
1 2 3 4 5 6 7
| Socket socket = new Socket ( "88.121.204.240" , port );
ObjectInputStream ois = new ObjectInputStream ( socket.getInputStream());
FileOutputStream out = new FileOutputStream("img.gif");
ObjectOutputStream s = new ObjectOutputStream(out);
Object o = ois.readObject ();
s.writeObject(o);
s.flush(); |
J'execute le Serveur, pas de prob; j'execute le Client : ERREUR :
java.io.NotSerializableException: sun.awt.image.URLImageSource
sur
oss.writeObject (new objet(image));
dans le Serveur
et java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: sun.awt.image.URLImageSource
sur
Object o = ois.readObject ();
Comment faire ?
Partager