How to read txt files and put your data in a vector

0

I'm trying to make a code that reads latitudes and longitudes that are in a txt file. ie put what is in the file in a vector and make a for loop to call all inside the polyline.

   try {

        File file = getFileStreamPath("circular_1.txt");//se eu puder usar uma variavel aki seria melhor pois o nome do arquivo vai ir sempre mudando
        int x = 0;
        FileReader reader = new FileReader(file);
        BufferedReader leitor = new BufferedReader(new InputStreamReader(getAssets().open("ufpa_circular_1.txt")));
        Double[] coord = new Double[192];
        String linha;
        while ((linha = leitor.readLine()) != null) {
            coord[x++] =Double.parseDouble(linha);
        }
        for (x = 0; x < 192; x = x + 2) {
            Polyline line = map.addPolyline(new PolylineOptions()
                    .add(new LatLng(coord[x], coord[x + 1]), new LatLng(coord[x + 2], coord[x + 3]))
                    .width(5)
                    .color(Color.BLUE));

        }
        leitor.close();
        reader.close();

    } catch (Exception e) {
        e.printStackTrace();
    }

The problem is that the polyline never appears when I put this code and I'm not finding the error in it. already tried putting the file in raw and using R.raw and in assets and using getAssets (), neither of them opened the polyline as well the lines are without limits, that is, I just gave myself permission to go to another line, but before I had made a text delimiting with; and using stringtokenizer and also did not appear the polylines

    
asked by anonymous 17.07.2015 / 19:56

0 answers