Java List from Array asList(byte[] array)

Here you can find the source of asList(byte[] array)

Description

as List

License

Open Source License

Declaration

public static List<Object> asList(byte[] array) 

Method Source Code


//package com.java2s;
/*//  ww  w  . ja  va2  s. c  o  m
 * JaLingo, http://jalingo.sourceforge.net/
 *
 * Copyright (c) 2002-2006 Oleksandr Shyshko
 *
 * 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 2 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<Object> asList(byte[] array) {
        return asList(array, 0, array.length);
    }

    public static List<Object> asList(byte[] array, int offset, int length) {
        List<Object> actualList = new ArrayList<Object>();
        for (int i = 0; i < length; i++) {
            actualList.add(array[i + offset]);
        }
        return actualList;
    }
}

Related

  1. arrayToListWithUpperCase(String[] arrValues)
  2. arrayToString(List arr)
  3. arrayToStringList(Object array)
  4. asList()
  5. asList(boolean[] array)
  6. asList(Class... classesArray)
  7. asList(Collection collection)
  8. asList(Collection collection, Class type)
  9. asList(Collection values)