Here you can find the source of subset(int start, int count, byte[] source)
Parameter | Description |
---|---|
start | index of the source to begin reading from |
count | number of bytes to copy |
source | byte array to read from |
count
public static byte[] subset(int start, int count, byte[] source)
//package com.java2s; /*//from ww w .j av a2 s . c o m * StreamUtility.java * * Created on October 26, 2002, 4:05 PM * * Copyright (C) 2002 Robert Cooper, Temple of the Screaming Penguin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ public class Main { /** * This is a quick method to get a subset of a byte array as a new array * @param start index of the source to begin reading from * @param count number of bytes to copy * @param source byte array to read from * @return byte array of size <code>count</code> */ public static byte[] subset(int start, int count, byte[] source) { byte[] ret = new byte[count]; for (int i = 0; i < count; i++) { ret[i] = source[start + i]; } return ret; } }