title: Optimizing method of input stream to read faster / Improving concatenation speed
body: <p>Currently I am reading a 100,0000+/- line input (example: <a href="http://pastebin.com/zhuHLcvA" rel="nofollow">http://pastebin.com/zhuHLcvA</a>) which ends with a single ";".</p>
  
  <p>Using this code it takes over 20 seconds to read on my pc (which is far too long):</p>
  
  <pre><code>public static String readFromStandardIO() {
  
      String returnValue = "";
  
      try {
          BufferedReader reader = new BufferedReader(new InputStreamReader(
                  System.in));
          String userInput;
          // System.out.println("Enter polynomials:\n");
          while (true) {
              userInput = reader.readLine();
              // System.out.println(userInput);
              returnValue = returnValue.concat(userInput);
              if (userInput.equals(";")) {
                  break;
              }
          }
  
      } catch (Exception e) {
  
      }
  
      return returnValue;
  
  }
  </code></pre>
  
  <p>Using a timing method I get odd results:</p>
  
  <pre><code>long start = System.nanoTime();
  pol = readFromStandardIO();
  long elaspedTime = System.nanoTime() - start;
  System.out.println("reading stream took: " + elaspedTime);      
  </code></pre>
  
  <p>and it ouputs:</p>
  
  <pre><code>reading stream took: 1914854722
  </code></pre>
  
  <p>It seems that the line concatenation is slowing everything down:</p>
  
  <pre><code>returnValue = returnValue.concat(userInput)
  </code></pre>
  
  <p>Without it everything is instantaneous.</p>
  
  <p>How do I go about improving the speed of concatenation?</p>