Class ByteOp

java.lang.Object
org.archive.util.ByteOp

public class ByteOp extends Object
  • Constructor Details

    • ByteOp

      public ByteOp()
  • Method Details

    • copy

      public static byte[] copy(byte[] src)
    • copy

      public static byte[] copy(byte[] src, int offset, int length)
    • cmp

      public static boolean cmp(byte[] input, byte[] want)
    • cmp

      public static boolean cmp(byte[] b1, int src1, byte[] b2, int src2, int n)
    • append

      public static byte[] append(byte[] a, byte[] b)
    • bytesToShort

      public static int bytesToShort(int b1, int b2)
    • bytesToShort

      public static int bytesToShort(byte[] bytes, int offset)
    • bytesToShort

      public static int bytesToShort(byte[] bytes)
    • readShort

      public static int readShort(DataInput in) throws IOException
      Throws:
      IOException
    • readShort

      public static int readShort(InputStream is) throws IOException
      Throws:
      IOException
    • writeShort

      public static void writeShort(OutputStream os, int shortVal) throws IOException
      Throws:
      IOException
    • writeShort

      public static void writeShort(byte[] buf, int offset, int shortVal)
    • bytesToInt

      public static long bytesToInt(int b1, int b2, int b3, int b4)
    • bytesToInt

      public static long bytesToInt(byte[] bytes, int offset)
    • bytesToInt

      public static long bytesToInt(byte[] bytes)
    • readInt

      public static long readInt(DataInput in) throws IOException
      Throws:
      IOException
    • readInt

      public static long readInt(InputStream is) throws IOException
      Throws:
      IOException
    • writeInt

      public static void writeInt(OutputStream os, long intVal) throws IOException
      Throws:
      IOException
    • writeInt

      public static void writeInt(byte[] buf, int offset, long intVal)
    • readNBytes

      public static byte[] readNBytes(InputStream is, int n) throws IOException
      Throws:
      IOException
    • readToNull

      public static byte[] readToNull(InputStream is) throws IOException
      Read, buffer, and return bytes from is until a null byte is encountered
      Parameters:
      is - InputStream to read from
      Returns:
      array of bytes read, INCLUDING TRAILING NULL
      Throws:
      IOException - if the underlying stream throws on, OR if the default maximum buffer size is reached before a null byte is found
      EOFException - if EOF is encountered before a null byte
    • readToNull

      public static byte[] readToNull(InputStream is, int maxSize) throws IOException
      Read, buffer, and return bytes from is until a null byte is encountered
      Parameters:
      is - InputStream to read from
      maxSize - maximum number of bytes to search for the null
      Returns:
      array of bytes read, INCLUDING TRAILING NULL
      Throws:
      IOException - if the underlying stream throws on, OR if the specified maximum buffer size is reached before a null byte is found
      EOFException - if EOF is encountered before a null byte
    • discardToNull

      public static int discardToNull(InputStream is) throws IOException
      Throws:
      IOException
    • drawHex

      public static String drawHex(byte[] b)
    • drawHex

      public static String drawHex(byte[] b, int bytesPerRow)
    • drawHex

      public static String drawHex(byte[] b, int offset, int length, int bytesPerRow)
    • readFile

      public byte[] readFile(File f) throws FileNotFoundException, IOException
      Throws:
      FileNotFoundException
      IOException