Java Integer Create toInt(String intValue, int defaultValue)

Here you can find the source of toInt(String intValue, int defaultValue)

Description

to Int

License

Open Source License

Declaration

public static int toInt(String intValue, int defaultValue) 

Method Source Code

//package com.java2s;
/***************************************************************************
 * Copyright (c) 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, Germany.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * //from w ww  . j  a v  a  2s.co m
 * Contributors:
 *    Eike Stepper - initial API and implementation
 **************************************************************************/

public class Main {
    public static int toInt(String intValue, int defaultValue) {
        try {
            return Integer.valueOf(intValue).intValue();
        } catch (Exception e) {
            return defaultValue;
        }
    }
}

Related

  1. toInt(short[] arr)
  2. toInt(String arr, String separator)
  3. toInt(String chars)
  4. toInt(String input, int defaultValue)
  5. toInt(String input, int offset, int length)
  6. toInt(String number)
  7. toInt(String numStr, int defaultValue)
  8. toInt(String param)
  9. toInt(String param)