import java.awt.*; import java.io.*; public class EcritureFichier { private int[] coordX; private int[] coordY; private int nbPoints; private boolean aMultiplier; public EcritureFichier(int[] coordX, int[] coordY, int nbPoints, boolean aMultiplier) { this.coordX = coordX; this.coordY = coordY; this.nbPoints = nbPoints; this.aMultiplier = aMultiplier; try { FileOutputStream fichier = new FileOutputStream("polygone.bin"); DataOutputStream flux = new DataOutputStream(fichier); try{ for (int i = 0; i != nbPoints; i++) { if (this.aMultiplier) { flux.writeInt(this.coordX[i]*2); flux.writeInt(this.coordY[i]*2); } else { flux.writeInt(this.coordX[i]/2); flux.writeInt(this.coordY[i]/2); } } } catch (IOException e2) { System.out.println("Erreur d'écriture"); } try { flux.close(); System.out.println("Fin de l'écriture"); } catch (IOException e3) { System.out.println("Erreur de fermeture"); } } catch (IOException e) { System.out.println("Erreur d'ouverture"); } } }