title: Reading data points from a data file
body: <p>I have a data file with 1000 data points that is organized like this:</p>
  
  <pre><code>1000
  16   11
  221   25
  234   112
  348   102
  451   456
  </code></pre>
  
  <p>I'm trying to read the file into my program and find an arrangement of the points that results in the shortest total point to point distance. Since I have little experience with lists, I'm having a lot of trouble even reading the data points. Is there a better way to go about this? How do you run the list through a nearest neighbor algorithm?</p>
  
  <pre><code>public static void main(String[] args) throws IOException {
      File file = new File("output.txt");
      Scanner scanner = new Scanner(file);
  
      ArrayList&lt;shortestRoute&gt; arrayList = new ArrayList&lt;shortestRoute&gt;();
  
      while (scanner.hasNextLine()) {
          String line = scanner.nextLine();
          String[] fields = line.split("   ");
  
          arrayList.add(new shortestRoute(Integer.parseInt(fields[0]), Integer.parseInt(fields[1])));
      }
      scanner.close();
  
      System.out.println(arrayList);
  }
  </code></pre>
  
  <p>I know that the formula for finding point to point distance is SquareRoot[(x2-x1)^2-(y2-y1)^2]. What I'm having trouble with is inputting the data points into the greedy algorithm.</p>