Java Integer Convert To fromIntegerString(String integerString)

Here you can find the source of fromIntegerString(String integerString)

Description

Deserializes an Integer from a given string.

License

Open Source License

Parameter

Parameter Description
integerString The Integer as string.

Return

The Integer object or null if the parsing failed.

Declaration

public static Integer fromIntegerString(String integerString) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Peter Lachenmaier - Cooperation Systems Center Munich (CSCM).
 * 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  w  w . java 2s  . co  m
 * Contributors:
 *     Peter Lachenmaier - Design and initial implementation
 ******************************************************************************/

public class Main {
    /**
     * Deserializes an Integer from a given string. 
     * 
     * @param integerString The Integer as string.
     * @return The Integer object or null if the parsing failed.
     */
    public static Integer fromIntegerString(String integerString) {

        if (integerString == null) {
            return null;
        }

        try {
            Integer i = new Integer(integerString);
            return i;
        } catch (Exception e) {
            // no output
        }

        // error case
        return null;

    }
}

Related

  1. fromInteger(int idx, Class clazz)
  2. fromInteger(int value)
  3. fromInteger(Integer value)
  4. fromInteger(Integer value, String defaultValue)
  5. fromIntegers(Integer[] values, String defaultValue)
  6. fromInternalForm(String internalForm)
  7. fromIntLong(byte[] value)
  8. fromInts(int[] values)
  9. fromIntString(Object obj)