Bonjour,
J'ai des petits soucis dans mon programme Java, je n'arrive pas à ecrire dans un fichier en misant à jour.
En effet, mon programme Java crée un fichier pour constituer un envoi de mail.
Le programme regarde si le fichier existe, s'il n'exite pas je le crée, sinon le programme doit faire des mises à jour dans le fichier ( incrementer les enregistrements ), c'est là ou je peche !
Help me
Premier code :
Deuxième code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 PrintWriter Outfic = new PrintWriter(new BufferedWriter(new FileWriter(ficsortie)),false); // DataOutputStream Outfic = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(ficsortie))); email = "-to " + quadrn +"@xx.com"; varbatch = this.Mailpgm + oespa + this.Mailbody + oespa + this.Mailsubject + oespa + this.Maillibelle + oespa + "-attach " +ficenv ; varbatch += oespa + email + oespa + "-cf " + this.Maillistecp ; System.out.println(" varbatch " + varbatch) ; if ( !ficsortie.exists() ) { // DataOutputStream Outfic = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(ficsortie))); Outfic.println(varbatch); // Outfic.writeBytes(varbatch); Outfic.close(); } else { // DataOutputStream Outfic = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(ficsortie))); Outfic.println(varbatch); Outfic.close(); }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 DataOutputStream Outfic = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(ficsortie))); email = "-to " + quadrn +"@xx.com"; varbatch = this.Mailpgm + oespa + this.Mailbody + oespa + this.Mailsubject + oespa + this.Maillibelle + oespa + "-attach " +ficenv ; varbatch += oespa + email + oespa + "-cf " + this.Maillistecp + "\n"; System.out.println(" varbatch " + varbatch) ; if ( !ficsortie.exists() ) { Outfic.writeBytes(varbatch); Outfic.close(); } else { Outfic.writeBytes(varbatch); Outfic.close(); }
Partager