Java Integer Create toInt(String s)

Here you can find the source of toInt(String s)

Description

to Int

License

Open Source License

Declaration

public static int toInt(String s) 

Method Source Code

//package com.java2s;

public class Main {
    public static int toInt(String s) {
        if ((s != null) && (!("".equals(s.trim()))))
            try {
                return Integer.parseInt(s);
            } catch (Exception e) {
                return 0;
            }/*from   w ww .j a  v a2 s. com*/

        return 0;
    }

    public static boolean equals(String s1, String s2) {
        if ((isEmpty(s1)) && (isEmpty(s2)))
            return true;
        if ((!(isEmpty(s1))) && (!(isEmpty(s2))))
            return s1.equals(s2);

        return false;
    }

    public static boolean isEmpty(String s) {
        return ((s == null) || ("".equals(s)));
    }

    public static String isEmpty(String s, String result) {
        if ((s != null) && (!(s.equals(""))))
            return s;

        return result;
    }
}

Related

  1. toInt(String number)
  2. toInt(String numStr, int defaultValue)
  3. toInt(String param)
  4. toInt(String param)
  5. toInt(String pString)
  6. toInt(String s)
  7. toInt(String s)
  8. toInt(String s, int defaultInt)
  9. toInt(String s, int exception)