Java Integer Parse tryParseInteger(String text)

Here you can find the source of tryParseInteger(String text)

Description

try Parse Integer

License

Apache License

Declaration

public static int tryParseInteger(String text) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int tryParseInteger(String text) {
        if ("".equals(text))
            return -1;

        try {/*  ww  w.ja  va2 s .co m*/
            return Integer.parseInt(text);
        } catch (NumberFormatException e) {
            return -1;
        }
    }
}

Related

  1. tryParseInt(String stringInt)
  2. tryParseInt(String text)
  3. tryParseInt(String value)
  4. tryParseInt(String value)
  5. tryParseInteger(String intValue)
  6. TryParseIntInvariant(String str, int[] n)
  7. tryParseInts(String[] in)