本文整理了Java中org.apache.kylin.common.util.Bytes.isHexDigit()
方法的一些代码示例,展示了Bytes.isHexDigit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bytes.isHexDigit()
方法的具体详情如下:
包路径:org.apache.kylin.common.util.Bytes
类名称:Bytes
方法名:isHexDigit
暂无
代码示例来源:origin: apache/kylin
public static byte[] toBytesBinary(String in) {
// this may be bigger than we need, but let's be safe.
byte[] b = new byte[in.length()];
int size = 0;
for (int i = 0; i < in.length(); ++i) {
char ch = in.charAt(i);
if (ch == '\\' && in.length() > i + 1 && in.charAt(i + 1) == 'x') {
// ok, take next 2 hex digits.
char hd1 = in.charAt(i + 2);
char hd2 = in.charAt(i + 3);
// they need to be A-F0-9:
if (!isHexDigit(hd1) || !isHexDigit(hd2)) {
// bogus escape code, ignore:
continue;
}
// turn hex ASCII digit -> number
byte d = (byte) ((toBinaryFromHex((byte) hd1) << 4) + (toBinaryFromHex((byte) hd2)) & 0xff);
b[size++] = d;
i += 3; // skip 3
} else {
b[size++] = (byte) ch;
}
}
// resize:
byte[] b2 = new byte[size];
System.arraycopy(b, 0, b2, 0, size);
return b2;
}
代码示例来源:origin: org.apache.kylin/kylin-core-common
public static byte[] toBytesBinary(String in) {
// this may be bigger than we need, but let's be safe.
byte[] b = new byte[in.length()];
int size = 0;
for (int i = 0; i < in.length(); ++i) {
char ch = in.charAt(i);
if (ch == '\\' && in.length() > i + 1 && in.charAt(i + 1) == 'x') {
// ok, take next 2 hex digits.
char hd1 = in.charAt(i + 2);
char hd2 = in.charAt(i + 3);
// they need to be A-F0-9:
if (!isHexDigit(hd1) || !isHexDigit(hd2)) {
// bogus escape code, ignore:
continue;
}
// turn hex ASCII digit -> number
byte d = (byte) ((toBinaryFromHex((byte) hd1) << 4) + (toBinaryFromHex((byte) hd2)) & 0xff);
b[size++] = d;
i += 3; // skip 3
} else {
b[size++] = (byte) ch;
}
}
// resize:
byte[] b2 = new byte[size];
System.arraycopy(b, 0, b2, 0, size);
return b2;
}
代码示例来源:origin: org.apache.kylin/kylin-common
public static byte[] toBytesBinary(String in) {
// this may be bigger than we need, but let's be safe.
byte[] b = new byte[in.length()];
int size = 0;
for (int i = 0; i < in.length(); ++i) {
char ch = in.charAt(i);
if (ch == '\\' && in.length() > i + 1 && in.charAt(i + 1) == 'x') {
// ok, take next 2 hex digits.
char hd1 = in.charAt(i + 2);
char hd2 = in.charAt(i + 3);
// they need to be A-F0-9:
if (!isHexDigit(hd1) || !isHexDigit(hd2)) {
// bogus escape code, ignore:
continue;
}
// turn hex ASCII digit -> number
byte d = (byte) ((toBinaryFromHex((byte) hd1) << 4) + toBinaryFromHex((byte) hd2));
b[size++] = d;
i += 3; // skip 3
} else {
b[size++] = (byte) ch;
}
}
// resize:
byte[] b2 = new byte[size];
System.arraycopy(b, 0, b2, 0, size);
return b2;
}
内容来源于网络,如有侵权,请联系作者删除!