public class ArchiveUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
isArrayZero(byte[] a,
int size)
Returns true if the first N bytes of an array are all zero
|
static boolean |
isEqual(byte[] buffer1,
byte[] buffer2)
Compare byte buffers
|
static boolean |
isEqual(byte[] buffer1,
byte[] buffer2,
boolean ignoreTrailingNulls)
Compare byte buffers, optionally ignoring trailing nulls
|
static boolean |
isEqual(byte[] buffer1,
int offset1,
int length1,
byte[] buffer2,
int offset2,
int length2)
Compare byte buffers
|
static boolean |
isEqual(byte[] buffer1,
int offset1,
int length1,
byte[] buffer2,
int offset2,
int length2,
boolean ignoreTrailingNulls)
Compare byte buffers, optionally ignoring trailing nulls
|
static boolean |
isEqualWithNull(byte[] buffer1,
int offset1,
int length1,
byte[] buffer2,
int offset2,
int length2)
Compare byte buffers, ignoring trailing nulls
|
static boolean |
matchAsciiBuffer(java.lang.String expected,
byte[] buffer)
Check if buffer contents matches Ascii String.
|
static boolean |
matchAsciiBuffer(java.lang.String expected,
byte[] buffer,
int offset,
int length)
Check if buffer contents matches Ascii String.
|
static java.lang.String |
sanitize(java.lang.String s)
Returns a "sanitized" version of the string given as arguments,
where sanitized means non-printable characters have been
replaced with a question mark and the outcome is not longer
than 255 chars.
|
static byte[] |
toAsciiBytes(java.lang.String inputString)
Convert a string to Ascii bytes.
|
static java.lang.String |
toAsciiString(byte[] inputBytes)
Convert an input byte array to a String using the ASCII character set.
|
static java.lang.String |
toAsciiString(byte[] inputBytes,
int offset,
int length)
Convert an input byte array to a String using the ASCII character set.
|
static java.lang.String |
toString(ArchiveEntry entry)
Generates a string containing the name, isDirectory setting and size of an entry.
|
public static java.lang.String toString(ArchiveEntry entry)
For example:
- 2000 main.c d 100 testfiles
entry
- the entrypublic static boolean matchAsciiBuffer(java.lang.String expected, byte[] buffer, int offset, int length)
expected
- expected stringbuffer
- the bufferoffset
- offset to read fromlength
- length of the buffertrue
if buffer is the same as the expected stringpublic static boolean matchAsciiBuffer(java.lang.String expected, byte[] buffer)
expected
- the expected strinbuffer
- the buffertrue
if buffer is the same as the expected stringpublic static byte[] toAsciiBytes(java.lang.String inputString)
inputString
- string to convertpublic static java.lang.String toAsciiString(byte[] inputBytes)
inputBytes
- bytes to convertpublic static java.lang.String toAsciiString(byte[] inputBytes, int offset, int length)
inputBytes
- input byte arrayoffset
- offset within arraylength
- length of arraypublic static boolean isEqual(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2, int length2, boolean ignoreTrailingNulls)
buffer1
- first bufferoffset1
- first offsetlength1
- first lengthbuffer2
- second bufferoffset2
- second offsetlength2
- second lengthignoreTrailingNulls
- whether to ignore trailing nullstrue
if buffer1 and buffer2 have same contents, having regard to trailing nullspublic static boolean isEqual(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2, int length2)
buffer1
- the first bufferoffset1
- the first offsetlength1
- the first lengthbuffer2
- the second bufferoffset2
- the second offsetlength2
- the second lengthtrue
if buffer1 and buffer2 have same contentspublic static boolean isEqual(byte[] buffer1, byte[] buffer2)
buffer1
- the first bufferbuffer2
- the second buffertrue
if buffer1 and buffer2 have same contentspublic static boolean isEqual(byte[] buffer1, byte[] buffer2, boolean ignoreTrailingNulls)
buffer1
- the first bufferbuffer2
- the second bufferignoreTrailingNulls
- whether to ignore tariling nullstrue
if buffer1 and buffer2 have same contentspublic static boolean isEqualWithNull(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2, int length2)
buffer1
- the first bufferoffset1
- the first offsetlength1
- the first lengthbuffer2
- the second bufferoffset2
- the second offsetlength2
- the second lengthtrue
if buffer1 and buffer2 have same contents, having regard to trailing nullspublic static boolean isArrayZero(byte[] a, int size)
a
- The array to checksize
- The number of characters to check (not the size of the array)public static java.lang.String sanitize(java.lang.String s)
This method is used to clean up file names when they are used in exception messages as they may end up in log files or as console output and may have been read from a corrupted input.
s
- the string to sanitizeCopyright © 2010 - 2020 Adobe. All Rights Reserved