Class ByteOp
java.lang.Object
org.archive.util.ByteOp
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]append(byte[] a, byte[] b) static longbytesToInt(byte[] bytes) static longbytesToInt(byte[] bytes, int offset) static longbytesToInt(int b1, int b2, int b3, int b4) static intbytesToShort(byte[] bytes) static intbytesToShort(byte[] bytes, int offset) static intbytesToShort(int b1, int b2) static booleancmp(byte[] input, byte[] want) static booleancmp(byte[] b1, int src1, byte[] b2, int src2, int n) static byte[]copy(byte[] src) static byte[]copy(byte[] src, int offset, int length) static intstatic StringdrawHex(byte[] b) static StringdrawHex(byte[] b, int bytesPerRow) static StringdrawHex(byte[] b, int offset, int length, int bytesPerRow) byte[]static longstatic longreadInt(InputStream is) static byte[]readNBytes(InputStream is, int n) static intstatic intreadShort(InputStream is) static byte[]Read, buffer, and return bytes from is until a null byte is encounteredstatic byte[]readToNull(InputStream is, int maxSize) Read, buffer, and return bytes from is until a null byte is encounteredstatic voidwriteInt(byte[] buf, int offset, long intVal) static voidwriteInt(OutputStream os, long intVal) static voidwriteShort(byte[] buf, int offset, int shortVal) static voidwriteShort(OutputStream os, int shortVal)
-
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
- Throws:
IOException
-
readShort
- Throws:
IOException
-
writeShort
- 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
- Throws:
IOException
-
readInt
- Throws:
IOException
-
writeInt
- Throws:
IOException
-
writeInt
public static void writeInt(byte[] buf, int offset, long intVal) -
readNBytes
- Throws:
IOException
-
readToNull
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 foundEOFException- if EOF is encountered before a null byte
-
readToNull
Read, buffer, and return bytes from is until a null byte is encountered- Parameters:
is- InputStream to read frommaxSize- 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 foundEOFException- if EOF is encountered before a null byte
-
discardToNull
- Throws:
IOException
-
drawHex
-
drawHex
-
drawHex
-
readFile
- Throws:
FileNotFoundExceptionIOException
-