0

I have 2 text files. One with x-coordinates and one with y-coordinates. Both are structured line by line like this:

21.21062
18.03474
14.43482
16.55259
18.66788
12.91812
17.07011

I want to retrieve both coordinates (first line of x + first line of y) then add into a function then move on to next line. Like this:

int line=0
    for(int i=0,i < 777,i++0)
        get xcord[line] {
        String x = xcord
        get ycord[line] {
        String y = ycord
        addPlace(x,y)
line++;
    }}

Hope you understand, I am not very good with arrays

EDIT: I know the line numbers of both text files (theyre the same though) if that helps

John Mill
  • 5
  • 1
  • 1
  • 4
  • You need to do two things: 1. Read about arrays: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html 2. File IO in Android: http://stackoverflow.com/questions/5771366/reading-a-simple-text-file Also couple of remarks about your psedo-code: 1. Your `for` loop has a syntactic error. Remove the 0 in the end (`i++0`). 2. You can get rid of the variable `line`as it has same values as `i`. – Balkrishna Rawool Jun 14 '15 at 21:17
  • Yeah the code was only for demo purpose, and the site really doesnt help me, it only shows how to open the file. The array site helped though, but it doesnt help me so much. Could you give me a piece of code to work of? – John Mill Jun 14 '15 at 21:22
  • Nevermind, I solved it, thanks! Post your answer as an answer if you want a correct answer :) – John Mill Jun 14 '15 at 21:51

1 Answers1

0

You can use Filereader. You have to create 2 different Filereader. And then you can get the texts from textfiles and add them to Arrays. If you learn enough about filereader you wil easily make what you want. It is really easy to use filereader.

987753
  • 12
  • 2