Bonjour, je souhaite réécrire dans un fichier texte:
Exemple, ouvir à nouveau le fichier nomFichier, aller à la fin puis continuer d'écrire. Que faut-il mettre entre le fw.close() et le fw.write() qui suit?
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
20
21
22
23
24
25
26 package testecriturefichier; import java.io.FileWriter; import java.io.IOException; public class Main { public static void main(String[] args) throws IOException { String nomFichier; System.out.println("Comment voulez-vous nommer le fichier texte (d'extension .txt) ? "); nomFichier = Clavier.lireString(); FileWriter fw = new FileWriter("C:\\Temp\\"+nomFichier+".txt"); fw.write("Bonjour\r\n");//retour à la ligne fw.write("Ecriture dans le fichier OK !"); fw.flush(); fw.close(); fw.write("Suite ecriture dans le fichier OK !"); } }
Merci pour vos informations,
Cordialement,
Malcolm
Partager