title: How can I read a string until I find a "text" in it (or somehow make the reading faster)?
body: <p>I have a class here, where I read a source of a webpage and search for a specific value. This typically takes 1 second to be completed, but I want it be shorter. My first guess, that this value is usually at the half of the page, so I might only read the half of it. </p>
  
  <pre><code>public class ReadData {
       public static void main(String[] args) throws IOException {
               StringBuilder line = new StringBuilder(1000000);
  
           URL url = new URL(url);
           HttpURLConnection conn = (HttpURLConnection) url.openConnection();
           BufferedReader rd = new BufferedReader(new InputStreamReader(conn
                   .getInputStream()));
           while (rd.readLine() != null) {
               line.append(rd.readLine());
               }
  
           long start = line.indexOf(startReading);
           long finish = line.indexOf(finishReading);
           String value= line.substring((int)start + 1, (int)finish);
           System.out.println("VALUE: " + value);
  
          }
  }
  </code></pre>
  
  <p>So now I read the whole text, then find the <code>startReading</code> and <code>finishReading</code> strings and I get the value between them. How can I read the source only till I find the <code>finishReading</code> string? Or is there any way to make the reading faster?</p>
  
  <p>Thanks in advance!</p>