android/guava/src/com/google/common/primitives/Floats.java
@Beta
  @GwtIncompatible // regular expressions
  @NullableDecl
  public static Float tryParse(String string) {
    if (Doubles.FLOATING_POINT_PATTERN.matcher(string).matches()) {
      // TODO(lowasser): could be potentially optimized, but only with
      // extensive testing
      try {
        return Float.parseFloat(string);
      } catch (NumberFormatException e) {
        // Float.parseFloat has changed specs several times, so fall through
        // gracefully
      }
    }
    return null;
  }
@Beta
  @GwtIncompatible // regular expressions
  @NullableDecl
  public static Float tryParse(String string) {
    if (Doubles.FLOATING_POINT_PATTERN.matcher(string).matches()) {
      // TODO(lowasser): could be potentially optimized, but only with
      // extensive testing
      try {
        return Float.parseFloat(string);
      } catch (NumberFormatException e) {
        // Float.parseFloat has changed specs several times, so fall through
        // gracefully
      }
    }
    return null;
  }
@ Beta @ GwtIncompatible // regular expressions @ NullableDecl public static Float tryParse ( String string ) { if ( Doubles . FLOATING_POINT_PATTERN . matcher ( string ) . matches ( ) ) { // TODO(lowasser): could be potentially optimized, but only with // extensive testing try { return Float . parseFloat ( string ) ; } catch ( NumberFormatException e ) { // Float.parseFloat has changed specs several times, so fall through // gracefully } } return null ; }
Parses the specified string as a single-precision floating point value. The ASCII character
{@code '-'} (<code>'&#92;u002D'</code>) is recognized as the minus sign.

<p>Unlike {@link Float#parseFloat(String)}, this method returns {@code null} instead of
throwing an exception if parsing fails. Valid inputs are exactly those accepted by {@link
Float#valueOf(String)}, except that leading and trailing whitespace is not permitted.

<p>This implementation is likely to be faster than {@code Float.parseFloat} if many failures
are expected.

@param string the string representation of a {@code float} value
@return the floating point value represented by {@code string}, or {@code null} if {@code
string} has a length of zero or cannot be parsed as a {@code float} value
@since 14.0
Parses the specified string as a single - precision floating point value . The ASCII character { @code - } ( <code > &#92 ; u002D < / code > ) is recognized as the minus sign .