salut,
j'ai écrit un programme qui me permet de lire un fichier et de faire des modification, et pour modifier le contenu j'ai utiliser un tableau ou je stocke les ligne puis je modifie la case correspondant et je réécrit mon fichier
je ne veux pas utiliser le tableau et j'aimerais utiliser FileOutputStream
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
27
28
29
30
31
32
33
34 //--modifier dat // 1ière étape lecture du dat String[] x=new String[7];//<-- nombre de ligne try { FileInputStream ips=new FileInputStream("C:\\data_spots\\getdata.dat"); InputStreamReader ipsr=new InputStreamReader(ips); BufferedReader br=new BufferedReader(ipsr); String ligne; int y = 0; System.out.println(br.readLine()); while ((ligne=br.readLine())!=null ) { String text = ligne; x[y]=text; y++; } br.close(); } catch (Exception e) { System.out.println(e.toString()); } } x[3]= "lcd C:\\data_spots"; for (int i=0;i<x.length;i++) { System.out.println(x[i]); }
si vous pouvez changer mon code j'en serais reconnaissant
Partager