Example usage for java.lang Integer toString

List of usage examples for java.lang Integer toString

Introduction

In this page you can find the example usage for java.lang Integer toString.

Prototype

@HotSpotIntrinsicCandidate
public static String toString(int i) 

Source Link

Document

Returns a String object representing the specified integer.

Usage

From source file:Main.java

public static String encodeXML(String value) {
    if (value == null)
        return "";
    StringBuilder result = new StringBuilder();
    for (int i = 0; i < value.length(); ++i) {
        char c = value.charAt(i);
        if (c >= 32 && c < 128)
            switch (c) {
            case '\'':
                result.append("&apos;");
                break;
            case '\"':
                result.append("&quot;");
                break;
            case '<':
                result.append("&lt;");
                break;
            case '>':
                result.append("&gt;");
                break;
            case '&':
                result.append("&amp;");
                break;
            default:
                result.append(c);/*from   ww  w .  j av a2  s  . co  m*/
            }
        else if (c != 0)
            result.append("&#").append(Integer.toString(c)).append(';');
    }
    return result.toString();
}

From source file:Main.java

/**
 * Get the version of this app as specified in the manifest.
 *
 * @param context/* www.  j  a va2  s  .c  om*/
 * @return String
 */
public static String getAppVersion(Context context) {
    try {
        PackageManager packageManager = context.getPackageManager();
        String version = packageManager.getPackageInfo(context.getPackageName(), 0).versionName;
        if (version == null)
            version = Integer.toString(packageManager.getPackageInfo(context.getPackageName(), 0).versionCode);
        return version;
    } catch (Exception ignored) {

    }
    return "Unknown";
}

From source file:Main.java

public static Element createTextElement(Element parent, String tagName, int v) {
    return createTextElement(parent, tagName, Integer.toString(v));
}

From source file:Main.java

private static TrustManager[] prepareTrustManager(InputStream... certificates) {
    if (certificates != null && certificates.length > 0) {
        try {//from w  w w.  j ava2s .  c  om
            CertificateFactory e = CertificateFactory.getInstance("X.509");
            KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
            keyStore.load((KeyStore.LoadStoreParameter) null);
            int index = 0;
            InputStream[] trustManagerFactory = certificates;
            int trustManagers = certificates.length;

            for (int i$ = 0; i$ < trustManagers; ++i$) {
                InputStream certificate = trustManagerFactory[i$];
                String certificateAlias = Integer.toString(index++);
                keyStore.setCertificateEntry(certificateAlias, e.generateCertificate(certificate));

                try {
                    if (certificate != null) {
                        certificate.close();
                    }
                } catch (IOException var10) {
                    ;
                }
            }

            trustManagerFactory = null;
            TrustManagerFactory var15 = TrustManagerFactory
                    .getInstance(TrustManagerFactory.getDefaultAlgorithm());
            var15.init(keyStore);
            TrustManager[] var16 = var15.getTrustManagers();
            return var16;
        } catch (NoSuchAlgorithmException var11) {
            var11.printStackTrace();
        } catch (CertificateException var12) {
            var12.printStackTrace();
        } catch (KeyStoreException var13) {
            var13.printStackTrace();
        } catch (Exception var14) {
            var14.printStackTrace();
        }

        return null;
    } else {
        return null;
    }
}

From source file:Main.java

public static String getMyDeviceId(Context context) {
    try {//from w  ww . jav a  2  s.c  o m
        WifiManager wifiMan = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiMan.getConnectionInfo();

        return Integer.toString(Math.abs(wifiInfo.getMacAddress().hashCode()));
    } catch (Exception e) {
        return "000000000000000000000";
    }

}

From source file:Main.java

/**
 * Convert "Friday X Month Year" to "YYYY-MM-DD"  
 * /*from  ww  w.  ja v  a  2s  .c o  m*/
 * @param Date_STR
 * @param conf
 * @return
 */
public static String dateSTR2Num(String Date_STR, Configuration conf) {

    String[] DateARR = Date_STR.split(" ");

    String DayNo = DateARR[1];
    String YearSTR = DateARR[3];

    //----- Month problem ------
    String MonthSTR = DateARR[2];

    DateFormatSymbols symbols = new DateFormatSymbols(conf.locale);
    String[] monthNames = symbols.getMonths();

    int iMonth = 0;

    for (int i = 0; i < monthNames.length; i++)
        if (MonthSTR.equals(monthNames[i]))
            iMonth = i;

    String MonthNo = Integer.toString(iMonth + 1);

    if (MonthNo.length() < 2)
        MonthNo = "0" + MonthNo;

    return YearSTR + "-" + MonthNo + "-" + DayNo;
}