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
| public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("mon tag", String.valueOf(12));
ArrayList<String> puissance = new ArrayList<>();
ArrayList<String> temps = new ArrayList<>();
FileInputStream input = null;
try {
//input = getApplicationContext().openFileInput("Matthieu1.gpx");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Log.d("mon tag", String.valueOf(14));
InputStream isr = getAssets().open("Matthieu1.gpx");
BufferedReader reader = new BufferedReader(isr);
int time;
time = 0;
int compteur;
compteur = -1;
String line = null;
try {
line = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
Log.d("mon tag", String.valueOf(16));
while (line !=null) {
//String[compteur] = ligne;
compteur++;
while (compteur == 11) {
compteur = 0;
temps.add(String.valueOf(time));
time++;
String delimiter = ">";
Pattern pattern = Pattern.compile(delimiter);
String[] element;
element = pattern.split(line);
//contrôle du résultat:
for(int i = 0; i < element.length; i++)
{
System.out.println(i + " >>>> " + element[i]);
}
String element1 = element[1];
String delimiter1 = "<";
Pattern pattern1 = Pattern.compile(delimiter1);
String[] element2;
element2 = pattern1.split(element1);
String valpuissance = element2[0];
puissance.add(String.valueOf(valpuissance));
}
try {
line = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
}
Log.d("mon tag", temps.toString());
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
isr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} |
Partager