54 lines
1.0 KiB
Java
54 lines
1.0 KiB
Java
import java.awt.*;
|
|
import java.io.*;
|
|
|
|
public class LectureFichier {
|
|
|
|
private int[] coordX;
|
|
private int[] coordY;
|
|
private int nbPoints;
|
|
|
|
public LectureFichier() {
|
|
|
|
try {
|
|
FileInputStream fichier = new FileInputStream("polygone.bin");
|
|
DataInputStream flux = new DataInputStream(fichier);
|
|
|
|
this.coordX = new int[flux.available()/8];
|
|
this.coordY = new int[flux.available()/8];
|
|
this.nbPoints = flux.available()/8;
|
|
|
|
int compteur = 0;
|
|
|
|
try {
|
|
while (flux.available() > 0) {
|
|
this.coordX[compteur] = flux.readInt();
|
|
this.coordY[compteur] = flux.readInt();
|
|
compteur++;
|
|
}
|
|
} catch (IOException e2) {
|
|
System.out.println("Erreur de lecture");
|
|
}
|
|
|
|
try {
|
|
flux.close();
|
|
} catch (IOException e3) {
|
|
System.out.println("Erreur de fermeture");
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
System.out.println("Erreur d'ouverture");
|
|
}
|
|
}
|
|
|
|
public int[] getCoordX() {
|
|
return this.coordX;
|
|
}
|
|
|
|
public int[] getCoordY() {
|
|
return this.coordY;
|
|
}
|
|
|
|
public int getNbPoints() {
|
|
return this.nbPoints;
|
|
}
|
|
} |