1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| //in et out sont ObjectInput(output)Stream
try
{
int taille_tableau;
byte[] tabImg;
//getBytesSansQualite(bufImage):methode qui retourne byte[]
tabImg=ImageKit.getBytesSansQualite(bufImage);
taille_tableau=tabImg.length;
System.out.println("Taille tab="+taille_tableau);
out.writeInt(taille_tableau);
out.write(tabImg);
System.out.println("FIN");
}
catch(AWTException e)
{
System.out.println("Erreur! ");
}
catch (UnknownHostException e) {
System.err.println("Nom de la machine est inconnu!!");
}
catch (IOException e) {
System.err.println("Erreur d E/S.");
}
catch (SecurityException e) {
System.err.println("Probleme de securite!!!");
}
Recepteur:
int taille_tab=in.readInt();
byte[] tabImg=new byte[taille_tab];
System.out.println("Avant la reception du tableau!!");
try
{
int nbrOcetRecu;
nbrOcetRecu=in.read(tabImg);
System.out.println("Tableau LU");
}
catch(Exception e)
{
System.out.println("Exception!!");
}
System.out.println("FIN"); |
Partager