Here you can find the source of startsWith(byte[] array, byte[] startBytes)
Parameter | Description |
---|---|
bytes | The array whose start is tested. |
startBytes | The byte array whose presence at the start of the array is tested. |
private static boolean startsWith(byte[] array, byte[] startBytes)
//package com.java2s; /*//from w w w .j a v a 2s .c o m * Copyright (c) 2006 - 2008 Aduna. * All rights reserved. * * Licensed under the Open Software License version 3.0. */ public class Main { /** * Determines whether the specified byte array starts with the specific bytes. * * @param bytes The array whose start is tested. * @param startBytes The byte array whose presence at the start of the array is tested. * @return 'true' when the array starts with the specified start bytes, 'false' otherwise. */ private static boolean startsWith(byte[] array, byte[] startBytes) { if (array == null || startBytes == null || array.length < startBytes.length) { return false; } for (int i = 0; i < startBytes.length; i++) { if (array[i] != startBytes[i]) { return false; } } return true; } }