Java tutorial
//package com.java2s; /* * Twittnuker - Twitter client for Android * * Copyright (C) 2013-2014 vanita5 <mail@vanita5.de> * * This program incorporates a modified version of Twidere. * Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.util.ArrayList; public class Main { public static long[] parseLongArray(final String string, final char token) { if (string == null) return new long[0]; final String[] items_string_array = string.split(String.valueOf(token)); final ArrayList<Long> items_list = new ArrayList<Long>(); for (final String id_string : items_string_array) { try { items_list.add(Long.parseLong(id_string)); } catch (final NumberFormatException e) { // Ignore. } } final int list_size = items_list.size(); final long[] array = new long[list_size]; for (int i = 0; i < list_size; i++) { array[i] = items_list.get(i); } return array; } }