Android String to Long Convert parseCSLongs(String s)

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

Description

parse CS Longs

License

Open Source License

Declaration

public static long[] parseCSLongs(String s) 

Method Source Code

//package com.java2s;

public class Main {
    public static long[] parseCSLongs(String s) {
        if (s == null) {
            return null;
        }/*from  w w  w  .  ja va  2s. co m*/

        String[] elements = s.split(",");
        long[] result = new long[elements.length];

        for (int index = 0; index < elements.length; index++) {
            Long value = parseLong(elements[index]);

            if (value != null) {
                result[index] = value;
            } else {
                return null;
            }
        }

        return result;
    }

    public static Long parseLong(String s) {
        try {
            return new Long(s);
        } catch (NumberFormatException e) {
            return null;
        }
    }
}

Related

  1. toLong(String str, long defValue)
  2. parseLong(String string, long defValue)
  3. convertStringToLong(String str, long failValue)
  4. stringToLong(String input)
  5. longsToString(long... longs)
  6. parseLong(String s)
  7. parseLongWithDefault(String s, long defValue)
  8. parseLong(String s, long iDefault)
  9. safeParseLong(String number, long fallback)