Java Array Length Get lengthNeeded(byte[] b)

Here you can find the source of lengthNeeded(byte[] b)

Description

length Needed

License

Open Source License

Declaration

public static int lengthNeeded(byte[] b) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int lengthNeeded(byte[] b) {
        if (b[0] != 0) {
            return 8;
        }/*from  ww  w  .j  a  v a  2s .c o  m*/
        if (b[1] != 0) {
            return 7;
        }
        if (b[2] != 0) {
            return 6;
        }
        if (b[3] != 0) {
            return 5;
        }
        if (b[4] != 0) {
            return 4;
        }
        if (b[5] != 0) {
            return 3;
        }
        if (b[6] != 0) {
            return 2;
        }
        if (b[7] != 0) {
            return 1;
        }
        return 0;
    }
}

Related

  1. length(T[] a)
  2. length3(float[] a)
  3. lengthArray(Object[][] arr)
  4. lengthCheck(double[] src, double[] dest)
  5. lengthCheck(final byte[] buffer, final byte length)
  6. lengthOf(T[] array)
  7. lengthOfShortestIn(String[] strings)
  8. lengthSQ(double[] vector)
  9. lengthToWrite(final byte[] data, final int offset, final int dataLength, final boolean rightTrim)