1 package be
.nikiroo
.utils
.streams
;
3 import be
.nikiroo
.utils
.StringUtils
;
6 * Some non-public utilities used in the stream classes.
12 * Check if the buffer starts with the given search term (given as an array,
13 * a start position and an end position).
15 * Note: the parameter <tt>stop</tt> is the <b>index</b> of the last
16 * position, <b>not</b> the length.
18 * Note: the search term size <b>must</b> be smaller or equal the internal
22 * the term to search for
24 * the buffer to look into
26 * the offset at which to start the search
28 * the maximum index of the data to check (this is <b>not</b> a
29 * length, but an index)
31 * @return TRUE if the search content is present at the given location and
32 * does not exceed the <tt>len</tt> index
34 static public boolean startsWith(byte[] search
, byte[] buffer
, int start
,
37 // Check if there even is enough space for it
38 if (search
.length
> (stop
- start
)) {
43 for (int i
= 0; i
< search
.length
; i
++) {
44 if (search
[i
] != buffer
[start
+ i
]) {
54 * Return the bytes array representation of the given {@link String} in
58 * the {@link String}s to transform into bytes
59 * @return the content in bytes
61 static public byte[][] getBytes(String
[] strs
) {
62 byte[][] bytes
= new byte[strs
.length
][];
63 for (int i
= 0; i
< strs
.length
; i
++) {
64 bytes
[i
] = StringUtils
.getBytes(strs
[i
]);