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;
}
} |
Partager