TP
This commit is contained in:
54
DEV2.1/TP12/03_Homothetie/LectureFichier.java
Normal file
54
DEV2.1/TP12/03_Homothetie/LectureFichier.java
Normal file
@@ -0,0 +1,54 @@
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user