java - store from list string to another array list -


i have txt file contains longitude , latitude coords:

120.12    22.233 100    23.12 98     19.12 

if want read file, doing:

list<string> lines = files.readalllines(paths.get(filename)); system.out.println("line: " + lines.get(0)); 

and gives me : 120 22

i have class reads latitude , longitude:

public class gispoints {      private double lat;     private double lon;      public gispoints() {     }      public gispoints(double lat, double lon) {        super();        this.lat = lat;        this.lon = lon;     }      //getters , setters } 

i want store values txt file list<gispoints>.

so, want function in order load file:

public static list<gispoints> loaddata(string filename) throws ioexception {        list<string> lines = files.readalllines(paths.get(filename));        list<gispoints> points = new arraylist<gispoints>();        //for (int = 0; < lines.size(); i++) {       // }        return points;    } 

as said, right reading every line, example lines[0] = 120 22

i want store lines[0] longitude points[0].setlon(), lines[0] latitude points[0].setlat().

it this:

    (int = 0; < lines.size(); i++)     {         string line = lines.get(i);          string[] values = line.split("\\s+");          double lat = double.parsedouble(values[0]);         double lon = double.parsedouble(values[1]);          points.add(new gispoints(lat, lon));     } 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -