Java Unsigned Int Create toUnsignedInt(String string)

Here you can find the source of toUnsignedInt(String string)

Description

to Unsigned Int

License

Open Source License

Parameter

Parameter Description
string string to convert to int

Return

int value if input positive, negative on error

Declaration

public static int toUnsignedInt(String string) 

Method Source Code

//package com.java2s;
/*//w  w w.ja  va  2s  . c  o m
 * Copyright Siemens AG, 2014-2016.
 * With modifications by Bosch Software Innovations GmbH, 2016
 * Part of the SW360 Portal Project.
 *
 * SPDX-License-Identifier: EPL-1.0
 *
 * 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
 */

public class Main {
    /**
     * @param string string to convert to int
     * @return int value if input positive, negative on error
     */
    public static int toUnsignedInt(String string) {
        int integer = -1;
        try {
            integer = Integer.valueOf(string);
        } catch (NullPointerException | NumberFormatException ignored) { // sic.
        }
        return integer;
    }
}

Related

  1. toUnsignedInt(char[] bytes, boolean le)
  2. toUnsignedInt(int i)
  3. toUnsignedInt(int value)
  4. toUnsignedInt(int value)
  5. toUnsignedInt(long value)
  6. toUnsignedInt16(byte[] bytes)
  7. toUnsignedInt32LittleEndian(byte[] bytes)
  8. toUnsignedIntArray(byte[] val)
  9. toUnsignedIntBigEndien(byte[] bytes)