类 ByteUtils

java.lang.Object
com.tencent.core.utils.ByteUtils

public class ByteUtils
extends java.lang.Object
  • 构造器概要

    构造器 
    构造器 说明
    ByteUtils()  
  • 方法概要

    修饰符和类型 方法 说明
    static byte[] concat​(byte[] bytes1, byte[] bytes2)
    合并两个byte[]
    static byte[] copy​(byte[] bs)  
    static byte[] inputStream2ByteArray​(java.io.File file)  
    static byte[] inputStream2ByteArray​(java.lang.String filePath)  
    static byte[] subBytes​(byte[] bs, int startIndex, int length)
    返回一个byte[]中指定的一部分。
    static java.util.List<byte[]> subToSmallBytes​(byte[] bs, int minLength, int maxLength)
    subToSmallBytes
    static java.util.List<byte[]> subToSmallBytes​(java.io.File file, int subLen)
    使用流的方式将文件读取一遍,然后切分成小的数组返回,数组大小为一个固定的值。
    static java.util.List<byte[]> subToSmallBytes​(java.io.InputStream inputStream, int subLen)
    切分成小的数组返回,数组大小为一个固定的值。

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

  • 方法详细资料

    • subBytes

      public static byte[] subBytes​(byte[] bs, int startIndex, int length)
      返回一个byte[]中指定的一部分。为了性能考虑,未对参数进行任何验证。
      参数:
      bs - 原byte[]
      startIndex - 开始索引
      length - 要拷贝的字节长度
      返回:
      byte[]中指定的一部分
      另请参阅:
      System.arraycopy(Object, int, Object, int, int)
    • copy

      public static byte[] copy​(byte[] bs)
    • concat

      public static byte[] concat​(byte[] bytes1, byte[] bytes2)
      合并两个byte[]
      参数:
      bytes1 - 第一个byte[]
      bytes2 - 第二个byte[]
      返回:
      合并后的数组
      抛出:
      java.lang.IllegalArgumentException - 如果任一参数为null
    • subToSmallBytes

      public static java.util.List<byte[]> subToSmallBytes​(byte[] bs, int minLength, int maxLength)
      subToSmallBytes
      参数:
      bs - bs
      minLength - minLength
      maxLength - maxLength
      返回:
      List
    • subToSmallBytes

      public static java.util.List<byte[]> subToSmallBytes​(java.io.File file, int subLen) throws java.io.FileNotFoundException
      使用流的方式将文件读取一遍,然后切分成小的数组返回,数组大小为一个固定的值。 切分大文件时会比subToSmallBytes(byte[], int, int)方法快一点。
      参数:
      file - 文件
      subLen - 切成指定的大小。
      返回:
      字节数组
      抛出:
      java.io.FileNotFoundException
    • subToSmallBytes

      public static java.util.List<byte[]> subToSmallBytes​(java.io.InputStream inputStream, int subLen)
      切分成小的数组返回,数组大小为一个固定的值。
      参数:
      inputStream - inputStream
      subLen - subLen
      返回:
      list
    • inputStream2ByteArray

      public static byte[] inputStream2ByteArray​(java.lang.String filePath)
    • inputStream2ByteArray

      public static byte[] inputStream2ByteArray​(java.io.File file)