Bonjour tout le monde,
je ne comprend pas pourquoi je n'arrive pas à récupérer mon tableau rightId.
Si quelqu'un pouvait m'aider à comprendre pourquoi
Voici la class qui contient le code fautif :
Et la method avec laquelle je l'appelle dans ma fonction principale :
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 import android.widget.Toast; import com.opencsv.CSVReader; import java.io.FileReader; import java.io.IOException; public class Rcsv { public int[] readThis(int id, int value) throws IOException { CSVReader reader = new CSVReader(new FileReader("C:\\AutoPlay_Android\\AutoPlay\\app\\src\\main\\res\\raw\\md.csv")); String[] nextLine; int rightId[] = new int[3]; int i = 0; while ((nextLine = reader.readNext()) != null) { // nextLine[] is an array of values from the line int idValue = Integer.parseInt(nextLine[id]); if (idValue == value || idValue == 2 || value == 2) { rightId[i] = Integer.parseInt(nextLine[0]); i = i++ ; } else {} } return rightId; } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 public int[] appelRead(int id, int value) { Rcsv rb = new Rcsv(); try { int[] ret = rb.readThis(id, value); return ret; } catch (IOException e) { e.printStackTrace(); } return null; }
Partager