Bonjour, je suis débutante avec java, je suis pas développeuse mais juste j'ai un travail à faire pour mon examen, alors pour m'expliquer, j'ai trois fichiers csv je veux les importer et les convertir en 3 tableaux tab1, tab2, tab3, pour pouvoir les utiliser. j'ai essayer ce code en suivant quelques tutoriels mais je suis pas satisfaite, où les trois tableaux ici pour pouvoir les parcourir dans une autre méthode:
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
 import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
 
public class tableau {
 
	public static void main(String[] args) {
        String fileName= "seq.csv";
        File file= new File(fileName);
 
        // this gives you a 2-dimensional array of strings
        List<List<String>> lines = new ArrayList<>();
        Scanner inputStream;
 
        try{
            inputStream = new Scanner(file);
 
            while(inputStream.hasNext()){
                String line= inputStream.next();
                String[] values = line.split(";");
                // this adds the currently parsed line to the 2-dimensional string array
                lines.add(Arrays.asList(values));
            }
 
            inputStream.close();
        }catch (FileNotFoundException e) {
            e.printStackTrace();
        }
 
        // the following code lets you iterate through the 2-dimensional array
        int lineNo = 1;
        for(List<String> line: lines) {
            int columnNo = 1;
            for (String value: line) {
                System.out.println("Line " + lineNo + " Column " + columnNo + ": " + value);
                columnNo++;
            }
            lineNo++;
        }
        String fileName1= "frequent-seq.csv";
        File file1= new File(fileName1);
 
        // this gives you a 2-dimensional array of strings
        List<List<String>> lines1 = new ArrayList<>();
        Scanner inputStream1;
 
        try{
            inputStream1 = new Scanner(file1);
 
            while(inputStream1.hasNext()){
                String line1= inputStream1.next();
                String[] values = line1.split(";");
                // this adds the currently parsed line to the 2-dimensional string array
                lines1.add(Arrays.asList(values));
            }
 
            inputStream1.close();
        }catch (FileNotFoundException e) {
            e.printStackTrace();
        }
 
        // the following code lets you iterate through the 2-dimensional array
        int lineNo1 = 1;
        for(List<String> line1: lines1) {
            int columnNo1 = 1;
            for (String value: line1) {
                System.out.println("Line " + lineNo1 + " Column " + columnNo1 + ": " + value);
                columnNo1++;
            }
            lineNo1++;
        }
        String fileName2= "lignes.csv";
        File file2= new File(fileName2);
 
        // this gives you a 2-dimensional array of strings
        List<List<String>> lines2 = new ArrayList<>();
        Scanner inputStream2;
 
        try{
            inputStream2 = new Scanner(file2);
 
            while(inputStream2.hasNext()){
                String line2= inputStream2.next();
                String[] values = line2.split(";");
                // this adds the currently parsed line to the 2-dimensional string array
                lines.add(Arrays.asList(values));
            }
 
            inputStream2.close();
        }catch (FileNotFoundException e) {
            e.printStackTrace();
        }
 
        // the following code lets you iterate through the 2-dimensional array
        int lineNo2 = 1;
        for(List<String> line2: lines2) {
            int columnNo2 = 1;
            for (String value: line2) {
                System.out.println("Line " + lineNo2 + " Column " + columnNo2 + ": " + value);
                columnNo2++;
            }
            lineNo1++;
        }
    }
 
}
quelqu'un peut m'aider pour avoir mes trois tableaux avec lesquels je vais utiliser des boucles for pour accéder aux cases et faire mon programme.