public final class BinaryFunctions extends Object
Modifier and Type | Method and Description |
---|---|
static int |
charsToQuad(char c1,
char c2,
char c3,
char c4) |
static boolean |
compareBytes(byte[] a,
int aStart,
byte[] b,
int bStart,
int length) |
static void |
copyStreamToStream(InputStream is,
OutputStream os) |
static int |
findNull(byte[] src) |
static int |
findNull(byte[] src,
int start) |
static byte[] |
getRAFBytes(RandomAccessFile raf,
long pos,
int length,
String exception) |
static byte[] |
getStreamBytes(InputStream is) |
static byte[] |
head(byte[] bytes,
int count) |
static void |
printByteBits(String msg,
byte i) |
static void |
printCharQuad(PrintWriter pw,
String msg,
int i) |
static void |
printCharQuad(String msg,
int i) |
static byte[] |
quadsToByteArray(int quad)
Convert a quad into a byte array.
|
static int |
read2Bytes(String name,
InputStream is,
String exception,
ByteOrder byteOrder) |
static int |
read3Bytes(String name,
InputStream is,
String exception,
ByteOrder byteOrder) |
static int |
read4Bytes(String name,
InputStream is,
String exception,
ByteOrder byteOrder) |
static void |
readAndVerifyBytes(InputStream is,
BinaryConstant expected,
String exception) |
static void |
readAndVerifyBytes(InputStream is,
byte[] expected,
String exception) |
static byte |
readByte(String name,
InputStream is,
String exception) |
static byte[] |
readBytes(InputStream is,
int count) |
static byte[] |
readBytes(String name,
InputStream is,
int length) |
static byte[] |
readBytes(String name,
InputStream is,
int length,
String exception) |
static byte[] |
remainingBytes(String name,
byte[] bytes,
int count) |
static boolean |
searchQuad(int quad,
InputStream bis)
Consumes the
InputStream (without closing it) searching for a quad. |
static void |
skipBytes(InputStream is,
long length) |
static void |
skipBytes(InputStream is,
long length,
String exception) |
static byte[] |
slice(byte[] bytes,
int start,
int count) |
static boolean |
startsWith(byte[] haystack,
BinaryConstant needle) |
static boolean |
startsWith(byte[] haystack,
byte[] needle) |
public static boolean startsWith(byte[] haystack, byte[] needle)
public static boolean startsWith(byte[] haystack, BinaryConstant needle)
public static byte readByte(String name, InputStream is, String exception) throws IOException
IOException
public static byte[] readBytes(String name, InputStream is, int length) throws IOException
IOException
public static byte[] readBytes(String name, InputStream is, int length, String exception) throws IOException
IOException
public static byte[] readBytes(InputStream is, int count) throws IOException
IOException
public static void readAndVerifyBytes(InputStream is, byte[] expected, String exception) throws ImageReadException, IOException
ImageReadException
IOException
public static void readAndVerifyBytes(InputStream is, BinaryConstant expected, String exception) throws ImageReadException, IOException
ImageReadException
IOException
public static void skipBytes(InputStream is, long length, String exception) throws IOException
IOException
public static byte[] remainingBytes(String name, byte[] bytes, int count)
public static byte[] slice(byte[] bytes, int start, int count)
public static byte[] head(byte[] bytes, int count)
public static boolean compareBytes(byte[] a, int aStart, byte[] b, int bStart, int length)
public static int read4Bytes(String name, InputStream is, String exception, ByteOrder byteOrder) throws IOException
IOException
public static int read3Bytes(String name, InputStream is, String exception, ByteOrder byteOrder) throws IOException
IOException
public static int read2Bytes(String name, InputStream is, String exception, ByteOrder byteOrder) throws IOException
IOException
public static void printCharQuad(String msg, int i)
public static void printCharQuad(PrintWriter pw, String msg, int i)
public static void printByteBits(String msg, byte i)
public static int charsToQuad(char c1, char c2, char c3, char c4)
public static byte[] quadsToByteArray(int quad)
quad
- quadpublic static boolean searchQuad(int quad, InputStream bis) throws IOException
InputStream
(without closing it) searching for a quad. It will
stop either when the quad is found, or when there are no more bytes in the input stream.
Returns true
if it found the quad, and false
otherwise.
quad
- a quad (the needle)bis
- an input stream (the haystack)true
if it found the quad, and false
otherwiseIOException
public static int findNull(byte[] src)
public static int findNull(byte[] src, int start)
public static byte[] getRAFBytes(RandomAccessFile raf, long pos, int length, String exception) throws IOException
IOException
public static void skipBytes(InputStream is, long length) throws IOException
IOException
public static void copyStreamToStream(InputStream is, OutputStream os) throws IOException
IOException
public static byte[] getStreamBytes(InputStream is) throws IOException
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.