Here you can find the source of bytesEqual(final byte[] source, final int offset, final byte[] target)
source
matches the byte-array in target
.
Parameter | Description |
---|---|
source | The source byte array |
offset | The offset of the sub-array within the source. |
target | The target byte array |
true
if the byte subarrays are equal
public static boolean bytesEqual(final byte[] source, final int offset, final byte[] target)
//package com.java2s; /**/*w w w . ja v a 2 s.com*/ * Copyright 2005-2012 Akiban Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Utility method to determine whether a subarray of bytes in a byte-array * <code>source</code> matches the byte-array in <code>target</code>. * * @param source * The source byte array * @param offset * The offset of the sub-array within the source. * @param target * The target byte array * @return <code>true</code> if the byte subarrays are equal */ public static boolean bytesEqual(final byte[] source, final int offset, final byte[] target) { for (int index = 0; index < target.length; index++) { if (source[index + offset] != target[index]) { return false; } } return true; } }