Here you can find the source of subByte(byte[] data, int start, int end)
Parameter | Description |
---|---|
data | a parameter |
start | a parameter |
end | a parameter |
public static byte[] subByte(byte[] data, int start, int end)
//package com.java2s; public class Main { /**// w w w . j a va 2s. c o m * @param data * @param start * @param end * @return */ public static byte[] subByte(byte[] data, int start, int end) { int len = data.length; if (start >= len || end <= start || end < 1) { return null; } byte[] result = new byte[(end - start)]; for (int i = start, j = 0; i < len; i++, j++) { if (i < end) { result[j] = data[i]; } else { break; } } return result; } public static byte[] subByte(byte[] data, int start) { int len = data.length; if (start >= len) { return null; } if (start < 0) { start = len + start; if (start < 0) { return null; } } byte[] result = new byte[(len - start)]; for (int i = start, j = 0; i < len; i++, j++) { result[j] = data[i]; } return result; } }