title: Java - Breaking out of a loop under certain conditions while parsing through text file
body: <p>I'm currently reading through a text file that looks something like this:</p>
  
  <pre><code>123 (1.0,4.4) (4,5)
  4 (2,1) (6.1,7) (1,3) (1,2)
  ...
  89122 (3,1) (56.1,1) (1.7,2)
  </code></pre>
  
  <p>It begins with a number followed by at least one pair of coordinates in the form (x,y). My goal: If one of the coordinates on the line matches what I'm looking for, I want to add the tag (the first number) to an arraylist and then break out of the loop right away. This is what I have so far:</p>
  
  <pre><code>ArrayList&lt;Integer&gt; matches = new ArrayList&lt;Integer&gt;();
  BufferedReader reader = new BufferedReader(new FileReader(new File(args[0])));
  
  String pattern =  "([0-9.]+),([0-9.]+)";
  Pattern p = Pattern.compile(pattern);
  Matcher m = null;
  String line;
  double x,y;
  
  while((line = reader.readLine()) != null) {
      String[] temp = line.split(" ", 2);  //this splits the tag from the rest of the line, which are pairs of (x,y)
      m = p.matcher(temp[1]);
      while(m.find()) {
          x = Double.parseDouble(m.group(1));
          y = Double.parseDouble(m.group(2));
  
          if(x &gt; 100 || y &gt; 100) {
              matches.add(temp[0]);
              break; // ***this only breaks out of this single if, but what I really want is to break out of the m.find() while loop and get reader to read in the next line.
          }
      }
  }
  </code></pre>
  
  <p>The problem I'm having is (* * *), commented out in the code above. How do I break out of the loop properly? </p>