title: Way to parseInt without try-catch in Java 8?
body: <p>Is there a better way to try to convert to int a string that can be or not an integer?
  Integer.parseInt(String value) will work well with &quot;25&quot; or &quot;019&quot; but not with &quot;hello&quot; or &quot;8A&quot;.
  In Java 8, we have optional values, for example:</p>
  <pre><code>public static void main(String[] args) {
      Optional&lt;Integer&gt; optionalResult = functionThatReturnsOptionalInteger();
      Integer finalValue = optionalResult.orElse(0);
      System.out.println(finalValue);
  }
  
  public static Optional&lt;Integer&gt; functionThatReturnsOptionalInteger() {
      Integer[] ints = new Integer[0];
      return Stream.of(ints).findAny();
  }
  </code></pre>
  <p>You do not need to check nulls, because the <code>Optional</code> wrapper expose useful methods to deal with this kind of situations.</p>
  <p>But if you want to <code>parseInt</code> a string, that can be null, or does not contains a valid integer, the solution is the same as always:</p>
  <pre><code>public static Integer parseIntOrDefault(String toParse, int defaultValue) {
      try {
          return Integer.parseInt(toParse);
      } catch (NumberFormatException e) {
          return defaultValue;
      }
  }
  </code></pre>
  <p>How can improve this with Java 8 features, why Integer.parseInt() has not been <strong>overloaded</strong> to <strong>return an Optional</strong> in case of bad argument? (Or just add a new method Integer.parseIntOptional() to Integer wrapper)</p>