Example usage for org.apache.commons.lang ArrayUtils EMPTY_INT_ARRAY

List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_INT_ARRAY

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils EMPTY_INT_ARRAY.

Prototype

null EMPTY_INT_ARRAY

To view the source code for org.apache.commons.lang ArrayUtils EMPTY_INT_ARRAY.

Click Source Link

Document

An empty immutable int array.

Usage

From source file:org.zaproxy.zap.control.AddOn.java

private static int[] toJavaVersionIntArray(String version, int limit) {
    if (version == null) {
        return ArrayUtils.EMPTY_INT_ARRAY;
    }/*  w ww  . j av  a  2  s .  c  o  m*/
    String[] strings = StringUtils.split(version, "._- ");
    int[] ints = new int[Math.min(limit, strings.length)];
    int j = 0;
    for (int i = 0; i < strings.length && j < limit; i++) {
        String s = strings[i];
        if (s.length() > 0) {
            try {
                ints[j] = Integer.parseInt(s);
                j++;
            } catch (Exception e) {
            }
        }
    }
    if (ints.length > j) {
        int[] newInts = new int[j];
        System.arraycopy(ints, 0, newInts, 0, j);
        ints = newInts;
    }
    return ints;
}