Skip to content

Commit

Permalink
Utilisation des BufferedStream pour accélérer lecture/écriture des ca…
Browse files Browse the repository at this point in the history
…rtes
  • Loading branch information
Cédric Connes authored and Cédric Connes committed Dec 22, 2011
1 parent 1c725fc commit f28ca44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/affichage/Camera.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

/**
* Classe abstraite représentant un caméra.<br>
* Cette classe est la passerelle entre une carte et
* un écran : elle est chargée d'afficher une vue de la carte dans la zone de dessin de l'écran.
* Cette classe est la passerelle entre une carte et un écran : elle est chargée d'afficher une vue
* de la carte dans la zone de dessin de l'écran.
* Une carte étant souvent trop grande pour s'afficher entièrement dans un écran, cette classe permet
* également de spécifier la zone à afficher.<br>
* Les différentes sous-classes doivent donc fournir différents moyen de se déplacer dans la
Expand Down
7 changes: 5 additions & 2 deletions src/modele/Carte.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import java.awt.Graphics;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -102,7 +104,7 @@ public String toString() {

public static void ecrire(Carte carte, File fichier) {
try {
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(fichier));
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(fichier)));
out.writeObject(carte);
out.close();
} catch (IOException e) {
Expand All @@ -121,7 +123,8 @@ public void ecrire(String nomFichier) {
public static Carte lire(File fichier) {
ObjectInputStream in;
try {
in = new ObjectInputStream(new FileInputStream(fichier));
in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(fichier)));
// in = new ObjectInputStream(new FileInputStream(fichier));
} catch (IOException e) {
System.err.println("Le fichier " + fichier + "ne peut pas être lu :\n" + e);
return null;
Expand Down

0 comments on commit f28ca44

Please sign in to comment.