下面列出了org.apache.commons.io.ByteOrderMark#length ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private final boolean checkBom(ByteOrderMark bom) {
int bomLength = bom.length();
if (bufferPtr + bomLength >= length) {
// Not enough bytes from the current position to the end of the buffer
return false;
}
if (BoundsChecking.BOUNDS_CHECKING_ENABLED) {
buffer.checkBytes(bufferPtr - 1, bufferPtr + bomLength);
}
byte[] bomBytes = bom.getBytes();
for (int i = 0; i < bomLength; i++) {
byte nextChar = PlatformDependent.getByte(bStartMinus1 + bufferPtr + i);
if (nextChar != bomBytes[i]) {
// No BOM. Position is unchanged
return false;
}
}
return true;
}
public int compare(ByteOrderMark bom1, ByteOrderMark bom2) {
int len1 = bom1.length();
int len2 = bom2.length();
if (len1 > len2) {
return -1;
}
if (len2 > len1) {
return 1;
}
return 0;
}
/**
* Check if the bytes match a BOM.
*
* @param bom
* The BOM
* @return true if the bytes match the bom, otherwise false
*/
private boolean matches(ByteOrderMark bom) {
// if (bom.length() != fbLength) {
// return false;
// }
// firstBytes may be bigger than the BOM bytes
for (int i = 0; i < bom.length(); i++) {
if (bom.get(i) != firstBytes[i]) {
return false;
}
}
return true;
}
public int compare(final ByteOrderMark bom1, final ByteOrderMark bom2) {
final int len1 = bom1.length();
final int len2 = bom2.length();
if (len1 > len2) {
return EOF;
}
if (len2 > len1) {
return 1;
}
return 0;
}
/**
* Check if the bytes match a BOM.
*
* @param bom
* The BOM
* @return true if the bytes match the bom, otherwise false
*/
private boolean matches(final ByteOrderMark bom) {
// if (bom.length() != fbLength) {
// return false;
// }
// firstBytes may be bigger than the BOM bytes
for (int i = 0; i < bom.length(); i++) {
if (bom.get(i) != firstBytes[i]) {
return false;
}
}
return true;
}