All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fisco.bcos.web3j.utils.Bytes Maven / Gradle / Ivy

package org.fisco.bcos.web3j.utils;

import java.util.Arrays;

/** Byte array utility functions. */
public class Bytes {

  private Bytes() {}

  public static byte[] trimLeadingBytes(byte[] bytes, byte b) {
    int offset = 0;
    for (; offset < bytes.length - 1; offset++) {
      if (bytes[offset] != b) {
        break;
      }
    }
    return Arrays.copyOfRange(bytes, offset, bytes.length);
  }

  public static byte[] trimLeadingZeroes(byte[] bytes) {
    return trimLeadingBytes(bytes, (byte) 0);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy