Here you can find the source of startWithBOM(byte[] array)
Parameter | Description |
---|---|
array | byte[], byte array to be tested |
true
if the array starts with BOM, false if the does not start with BOM
Declaration
public static final boolean startWithBOM(byte[] array)
Method Source Code
//package com.java2s;
//License from project: LGPL
public class Main {
/** Byte-order mark. */
private static final String BOM = "\uFEFF";
/**// w w w. j a v a 2 s . c o m
* Test if the byte array starts with BOM.
*
* @param array
* byte[], byte array to be tested
* @return <code>true</code> if the array starts with BOM,
* <code>false if the {@link String} does not start with BOM
*/
public static final boolean startWithBOM(byte[] array) {
if (array.length < 3) {
return false;
}
if ((array[0] != (byte) 0xEF) || (array[1] != (byte) 0xBB) || (array[2] != (byte) 0xBF)) {
return false;
}
return true;
}
/**
* Test if the byte array starts with BOM.
*
* @param text
* {@link String}, string to be tested
* @return <code>true</code> if the string starts with BOM,
* <code>false if the {@link String} does not start with BOM
*/
public static final boolean startWithBOM(String text) {
return text.startsWith(BOM);
}
}
Related
- startWith(String str, String prefix)
- startWith(String str, String start)
- startWith(String string, String prefix)
- startWith(String string1, String string2)
- startWithAorAn(String str)
- startWithIgnoreCase(CharSequence str, CharSequence prefix)
- startWithIgnoreCase(String str, String prefix)
- startWithLowerCase(String in)
- startWithLowerCase(String methodName)