Java String to Int convertStringToInt(final String str)

Here you can find the source of convertStringToInt(final String str)

Description

Convert the specified string into an integer.

License

Open Source License

Parameter

Parameter Description
str the string to convert

Return

the integer value for the string

Declaration

private static int convertStringToInt(final String str) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**// w w  w  . j  a  v  a  2s  .  c  o m
     * Convert the specified string into an integer.
     * 
     * @param str the string to convert
     * @return the integer value for the string
     */
    private static int convertStringToInt(final String str) {
        int val = -1;

        try {
            val = Integer.parseInt(str);
        } catch (NumberFormatException nfe) {
            val = -1;
        }

        return val;
    }
}

Related

  1. asInteger(String param)
  2. asInteger(String string)
  3. asInteger(String v)
  4. asInteger(String value)
  5. asInteger(String value)
  6. convertStringToInt(final String strNumber)
  7. convertStringToInt(String number)
  8. convertStringToInt(String str)
  9. convertStringToInt(String value)