提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
检查给定的字节数组是否只包含零。
//package com.nowjava; public class Main {//来自 NowJava.com public static void main(String[] argv) throws Exception { byte[] array = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; System.out.println(byteArrayBlank(array)); } /** * Check whether a given byte array contains only zeroes. */ public static final boolean byteArrayBlank(byte[] array) { return byteArraySliceBlank(array, 0, array.length); } /**N o w J a v a . c o m - 时 代 Java**/ /** * Check whether a byte array slice contains only zeroes. * * @param array * base array * @param start * first offset of the slice to be scanned * @param length * length of the slice to be scanned */ public static final boolean byteArraySliceBlank(final byte[] array, final int start, final int length) {