Java Short Number Create toShort(String input, short defaultValue)

Here you can find the source of toShort(String input, short defaultValue)

Description

to Short

License

Apache License

Declaration

public static short toShort(String input, short defaultValue) 

Method Source Code

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

public class Main {
    public static short toShort(String input, short defaultValue) {
        try {//from ww  w.  jav  a2 s. co  m
            return Short.parseShort(input);
        } catch (Exception e) {
            return defaultValue;
        }
    }

    public static short toShort(String input, int radix, short defaultValue) {
        try {
            return Short.parseShort(input, radix);
        } catch (Exception e) {
            return defaultValue;
        }
    }
}

Related

  1. toShort(Object value)
  2. toShort(Object value)
  3. toShort(Object value)
  4. toShort(Object value)
  5. toShort(Object value)
  6. toShort(String numeric)
  7. toShort(String str)
  8. toShort(String str)
  9. toShort(String str, int maxLen)