Here you can find the source of lengthToZero(byte[] data, int offset)
public static int lengthToZero(byte[] data, int offset)
//package com.java2s; public class Main { public static int lengthToZero(byte[] data, int offset) { int start = offset; for (int i = start; i < data.length; i++) { if (data[i] == 0) { return (i - start); }/*from w w w. j a v a 2 s. co m*/ } int remaining = data.length - start; return remaining > 0 ? remaining : 0; } }