If you think the Android project makler listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package pl.net.newton.Makler.history;
/*fromwww.java2s.com*/import java.util.Calendar;
publicfinalclass ByteArrayUtils {
private ByteArrayUtils() {
}
publicstaticint search(byte[] needle, byte[] haystack, int from, int to) {
for (int i = from; i < to - needle.length; i++) {
boolean ok = true;
for (int j = 0; j < needle.length; j++) {
if (needle[j] != haystack[i + j]) {
ok = false;
break;
}
}
if (ok) {
return i;
}
}
return -1;
}
publicstaticint nextLine(byte[] haystack, int offset) {
return findNext((byte) '\n', haystack, offset) + 1;
}
publicstaticint findNext(byte needle, byte[] haystack, int offset) {
for (int i = offset; i < haystack.length; i++) {
if (haystack[i] == needle) {
return i;
}
}
return -1;
}
publicstaticlong[] parseLong(byte[] array, int offset, long[] result) {
return parseLong(array, offset, 0, result);
}
publicstaticlong[] parseLong(byte[] array, int offset, int multiplier, long[] result) {
result[0] = 0;
boolean decimal = false;
int i, m = multiplier;
for (i = offset; i < array.length; i++) {
finalbyte digit = array[i];
if (digit == '.') {
decimal = true;
} elseif ((digit < '0' || digit > '9') || (decimal && m == 0)) {
break;
} else {
result[0] *= 10;
result[0] += array[i] - '0';
if (decimal) {
m--;
}
}
}
for (int j = 0; j < m; j++) {
result[0] *= 10;
}
result[1] = i;
return result;
}
publicstaticvoid setDate(Calendar cal, long date) {
int year = (int) (date / 10000);
int month = (int) ((date / 100) % 100);
int day = (int) (date % 100);
cal.set(year, month - 1, day);
}
publicstaticvoid setTime(Calendar cal, long time) {
int hour = (int) (time / 10000);
int minute = (int) ((time / 100) % 100);
int second = (int) (time % 100);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
cal.set(Calendar.SECOND, second);
}
}