Package org.apache.commons.io
Class ByteOrderMark
java.lang.Object
org.apache.commons.io.ByteOrderMark
- All Implemented Interfaces:
Serializable
Byte Order Mark (BOM) representation. See
BOMInputStream
.
We define the follow BOM constants:
Deprecating Serialization
Serialization is deprecated and will be removed in 3.0.
- Since:
- 2.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ByteOrderMark
UTF-16BE BOM (Big-Endian).static final ByteOrderMark
UTF-16LE BOM (Little-Endian).static final ByteOrderMark
UTF-32BE BOM (Big-Endian).static final ByteOrderMark
UTF-32LE BOM (Little-Endian).static final ByteOrderMark
UTF-8 BOM.static final char
Unicode BOM character; external form depends on the encoding. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates if this instance's bytes equals another.int
get
(int pos) Gets the byte at the specified position.byte[]
getBytes()
Gets a copy of the BOM's bytes.Gets the name of theCharset
the BOM represents.int
hashCode()
Computes the hash code for this BOM.int
length()
Gets the length of the BOM's bytes.boolean
matches
(int[] test) Tests whether the given array starts with the bytes for this BOM.toString()
Converts this instance to a String representation of the BOM.
-
Field Details
-
UTF_8
UTF-8 BOM.This BOM is:
0xEF 0xBB 0xBF
-
UTF_16BE
UTF-16BE BOM (Big-Endian).This BOM is:
0xFE 0xFF
-
UTF_16LE
UTF-16LE BOM (Little-Endian).This BOM is:
0xFF 0xFE
-
UTF_32BE
UTF-32BE BOM (Big-Endian).This BOM is:
0x00 0x00 0xFE 0xFF
- Since:
- 2.2
-
UTF_32LE
UTF-32LE BOM (Little-Endian).This BOM is:
0xFF 0xFE 0x00 0x00
- Since:
- 2.2
-
UTF_BOM
Unicode BOM character; external form depends on the encoding.- Since:
- 2.5
- See Also:
-
-
Constructor Details
-
ByteOrderMark
Constructs a new instance.- Parameters:
charsetName
- The name of the charset the BOM representsbytes
- The BOM's bytes- Throws:
IllegalArgumentException
- if the charsetName is zero lengthIllegalArgumentException
- if the bytes are zero length
-
-
Method Details
-
equals
Indicates if this instance's bytes equals another. -
get
Gets the byte at the specified position.- Parameters:
pos
- The position- Returns:
- The specified byte
-
getBytes
Gets a copy of the BOM's bytes.- Returns:
- a copy of the BOM's bytes
-
getCharsetName
Gets the name of theCharset
the BOM represents.- Returns:
- the character set name
-
hashCode
Computes the hash code for this BOM. -
length
Gets the length of the BOM's bytes.- Returns:
- the length of the BOM's bytes
-
matches
Tests whether the given array starts with the bytes for this BOM.- Parameters:
test
- the array to test.- Returns:
- whether the given array starts with the bytes for this BOM.
- Since:
- 2.19.0
-
toString
Converts this instance to a String representation of the BOM.
-