Problème gestion de fichier
Bonjour à tous !
J'ai un problème qui me rend dingue et dont je ne trouve pas la solution. Je me suis créé une classe qui me permet de gérer un fichier temporaire (écrire, modifier et supprimer) et chose que je ne comprend pas c'est que lorsque j'instancie ma classe à plusieurs attribut et bien il gère que le dernier attribut qui aura été instancié.
Voici mon code ce sera certainement plus parlant :
Ma classe FileTmp
Code:
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
|
private static File f;
/** CONSTRUCTEUR DE LA CLASSE
* @param Path
* @throws java.io.IOException */
public FileTmp(String Path) throws IOException{
f = new File(Path);
f.createNewFile();
}
/** ECRITURE DES DONNEE POUR LA CHAMBRE */
void WriteFileTmpCustomer(List<String[]> dataCustomer) throws IOException{
ArrayList<String[]> datacustomer = new ArrayList<>(dataCustomer);
//File ff = new File(pathfiletmp); // définir l'arborescence
//ff.createNewFile();
try (FileWriter ffw = new FileWriter(f)) {
ffw.write("[CUSTOMER]\n");
for (Iterator<String[]> iterator = datacustomer.iterator(); iterator.hasNext();) {
String[] next = iterator.next();
try{
for(int i = 0; i <= 10;i++){
ffw.write(next[i] + " ");
}
}catch (Exception e){
jop1.showMessageDialog(null, "Impossible d'écrire dans le fichier temporaire\n" +
"Détail de l'erreur :\n" + e, "Erreur", JOptionPane.ERROR_MESSAGE);
}
}
ffw.close(); // fermer le fichier à la fin des traitements
}
} |
Ma classe où j'instancie ma classe FileTmp
Code:
1 2 3 4
|
/** Création des fichiers temporaire pour enregistrement des données */
filetmpTypeRoom = new FileTmp(System.getProperty("user.dir") + "\\tmpTypeRoom.txt");
filetmpRoom = new FileTmp(System.getProperty("user.dir") + "\\tmpRoom.txt"); |
Je vous remercie d'avance à tous pour votre aide.